Appium scroll 滑动查找

首先看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) 再获取子元素

posted @ 2016-03-18 09:20  皮斯卡略夫  阅读(4209)  评论(0编辑  收藏  举报