appium(9)-uiautomator UiSelector

uiautomator UiSelector

Appium enables searching using UiSelectors. UiScrollable is also supported.//Uiselector和UiScrollable两种定位方式。

Note that the index selector is unreliable so prefer instance instead. The following examples are written against the api demos apk using Ruby.

Find the first textview.

1 # ruby
2 first_textview = find_element(:uiautomator, 'new UiSelector().className("android.widget.TextView").instance(0)');

 

Find the first element by text.

1 # ruby
2 first_text = find_element(:uiautomator, 'new UiSelector().text("Animation")')
3 first_text.text # "Animation"

 

Find the first scrollable element, then find a TextView with the text “Tabs”. The “Tabs” element will be scrolled into view.

1 # ruby
2 element = find_element(:uiautomator, 'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "Tabs")')

 

As a special case, scrollIntoView returns the element that is scrolled into view. scrollIntoView allows scrolling to any UiSelector.

posted @ 2016-11-15 19:42  超级宝宝11  阅读(840)  评论(0编辑  收藏  举报