元素定位方法之Uiautomator方法
这个方法只能用于安卓系统,方法通过类UiSelector()来构造对象的 官网地址: https://developer.android.google.cn/topic/libraries/testing-support-library/index.html#UIAutomator 打开链接到 UiSelector 类 https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html 定位方法:driver.find_element_by_android_uiautomator( 'new UiSelector().text("9")') 返回元素对象 通过元素文本进行定位: 1、根据文本定位 text(String text) new UiSelector().text("9") 2、模糊匹配文本 textContains(文本) 3、以某个文本开头来匹配 textStartsWith(文本) 4、正则匹配 textMatches(正则表达式) new UiSelector().textMatches("^D.*" ) 根据 resourceId 定位元素: resourceId(id) new UiSelector()