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) 再獲取子元素


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM