text定位:
driver.find_element_by_android_uiautomator('new UiSelector().text("请输入手机号")')
#模糊定位
driver.find_element_by_android_uiautomator('new UiSelector().textContains("请输入")')
resourceID定位:
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("cn.com.open.mooc:id/et_phone_edit")')
className定位:
driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.EditText")')
index 定位:
driver.find_element_by_android_uiautomator('new UiSelector().index(1)')
className + index 方式:
driver.find_element_by_android_uiautomator(
'new UiSelector().className("%s").childSelector(new UiSelector().index("%d"))')
伪xpath方法定位:
#通过同级元素定位同级元素
driver.find_element_by_android_uiautomator(‘new UiSelector().text("Custom View").fromParent(new UiSelector().text("Accessibility Service"))‘).click()
#通过父级元素定位子集元素
driver.find_element_by_android_uiautomator(‘new UiSelector().className("android.widget.ListView").childSelector(new UiSelector().text("Custom View"))‘).click()