最近刚好有个任务要搞一下Android自动化测试:推荐使用appium+python-client的框架,比较简单实用。 Uiautormator框架用Java实现的话: new UiScrollable(new UiSelector().className("android.support.v7.widget.RecyclerView")).getChildByText(new UiSelector().className("android.widget.RelativeLayout"), "中国移动",true);
但是对应到python+appium框架的话网上只能找到指定坐标来滑动屏幕。找到对应的方法也报错,甚至一度想要自己封装一下swipe方法来实现,后来找到了方法:
ua_scroll = 'new UiScrollable(new UiSelector().className("android.support.v7.widget.RecyclerView")).scrollIntoView(new UiSelector().text("中国移动"))' self.driver.find_element_by_android_uiautomator(ua_scroll).click()
该方法亲测有效,可以试一下