Appium 【已解决】请教一下 appuim 下定位问题。

顾铖 · 2014年05月06日 · 最后由 唐僧之妈 回复于 2014年05月06日 · 1684 次阅读

使用的是官网上 ContactManager 的例子,使用 UI automator view 查看定位。

@Test
   public void addContact(){
   WebElement el = driver.findElement(By.name("Add Contact"));
       el.click();
       List <WebElement> textFieldsList = driver.findElements(By.tagName("textfield"));
       textFieldsList.get(0).sendKeys("Some Name");
       textFieldsList.get(2).sendKeys("Some@example.com");
       driver.findElement(By.name("Save")).click();
   }

但是我没搞明白,怎么就看出来这个"Save"按钮的 name 值是 “Save”,输入框的 tagName 是"textfield"了呢?UI automator view 里没有显示啊。

共收到 4 条回复 时间 点赞

你的 Appium 版本是?如果是 1.0,就改为 Class_Name,如果是 1.0 以下版本,是因为 Appium 做了映射 map.put("textfield", "EditText");

映射全列表

map.put("abslist", "AbsListView");
map.put("absseek", "AbsSeekBar");
map.put("absspinner", "AbsSpinner");
map.put("absolute", "AbsoluteLayout");
map.put("adapterview", "AdapterView");
map.put("adapterviewanimator", "AdapterViewAnimator");
map.put("adapterviewflipper", "AdapterViewFlipper");
map.put("analogclock", "AnalogClock");
map.put("appwidgethost", "AppWidgetHostView");
map.put("autocomplete", "AutoCompleteTextView");
map.put("button", "Button");
map.put("breadcrumbs", "FragmentBreadCrumbs");
map.put("calendar", "CalendarView");
map.put("checkbox", "CheckBox");
map.put("checked", "CheckedTextView");
map.put("chronometer", "Chronometer");
map.put("compound", "CompoundButton");
map.put("datepicker", "DatePicker");
map.put("dialerfilter", "DialerFilter");
map.put("digitalclock", "DigitalClock");
map.put("drawer", "SlidingDrawer");
map.put("expandable", "ExpandableListView");
map.put("extract", "ExtractEditText");
map.put("fragmenttabhost", "FragmentTabHost");
map.put("frame", "FrameLayout");
map.put("gallery", "Gallery");
map.put("gesture", "GestureOverlayView");
map.put("glsurface", "GLSurfaceView");
map.put("grid", "GridView");
map.put("gridlayout", "GridLayout");
map.put("horizontal", "HorizontalScrollView");
map.put("image", "ImageView");
map.put("imagebutton", "ImageButton");
map.put("imageswitcher", "ImageSwitcher");
map.put("keyboard", "KeyboardView");
map.put("linear", "LinearLayout");
map.put("list", "ListView");
map.put("media", "MediaController");
map.put("mediaroutebutton", "MediaRouteButton");
map.put("multiautocomplete", "MultiAutoCompleteTextView");
map.put("numberpicker", "NumberPicker");
map.put("pagetabstrip", "PageTabStrip");
map.put("pagetitlestrip", "PageTitleStrip");
map.put("progress", "ProgressBar");
map.put("quickcontactbadge", "QuickContactBadge");
map.put("radio", "RadioButton");
map.put("radiogroup", "RadioGroup");
map.put("rating", "RatingBar");
map.put("relative", "RelativeLayout");
map.put("row", "TableRow");
map.put("rssurface", "RSSurfaceView");
map.put("rstexture", "RSTextureView");
map.put("scroll", "ScrollView");
map.put("search", "SearchView");
map.put("seek", "SeekBar");
map.put("space", "Space");
map.put("spinner", "Spinner");
map.put("stack", "StackView");
map.put("surface", "SurfaceView");
map.put("switch", "Switch");
map.put("tabhost", "TabHost");
map.put("tabwidget", "TabWidget");
map.put("table", "TableLayout");
map.put("text", "TextView");
map.put("textclock", "TextClock");
map.put("textswitcher", "TextSwitcher");
map.put("texture", "TextureView");
map.put("textfield", "EditText");
map.put("timepicker", "TimePicker");
map.put("toggle", "ToggleButton");
map.put("twolinelistitem", "TwoLineListItem");
map.put("video", "VideoView");
map.put("viewanimator", "ViewAnimator");
map.put("viewflipper", "ViewFlipper");
map.put("viewgroup", "ViewGroup");
map.put("viewpager", "ViewPager");
map.put("viewstub", "ViewStub");
map.put("viewswitcher", "ViewSwitcher");
map.put("web", "android.webkit.WebView");
map.put("window", "FrameLayout");
map.put("zoom", "ZoomButton");
map.put("zoomcontrols", "ZoomControls");

#1 楼 @xiaomayi0323 原来是这个意思,明白了,谢谢。

我也想问同样的问题,十分感谢!

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册