首先看uiautomator如何实现滑动查找
UiScrollable scrollView = new UiScrollable(new UiSelector().className("android.widget" +
".ScrollView"));
UiObject itemApps = scrollView.getChildByText(new UiSelector().className("android.widget" +
".TextView"),"Apps");
itemApps.click();
new一个 Uiscrollable 的对象,然后用getChild 的方法找到子元素。
Appium (Python-client)
def _find_by_scroll(self, item_name):
item = self.driver.find_element_by_android_uiautomator(
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "'
+ item_name + '")')
item.click()
区别还是有的,用scrollable(true)
找到对象,.instance(0)
再获取子元素