text定位:
driver.find_element_by_android_uiautomator('new UiSelector().text("請輸入手機號")')android
#模糊定位
driver.find_element_by_android_uiautomator('new UiSelector().textContains("請輸入")')ui
resourceID定位:
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("cn.com.open.mooc:id/et_phone_edit")')spa
className定位:
driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.EditText")')element
index 定位:
driver.find_element_by_android_uiautomator('new UiSelector().index(1)')get
className + index 方式:
driver.find_element_by_android_uiautomator(
'new UiSelector().className("%s").childSelector(new UiSelector().index("%d"))')it
僞xpath方法定位:class
#經過同級元素定位同級元素
driver.find_element_by_android_uiautomator(‘new UiSelector().text("Custom View").fromParent(new UiSelector().text("Accessibility Service"))‘).click() cli
#經過父級元素定位子集元素
driver.find_element_by_android_uiautomator(‘new UiSelector().className("android.widget.ListView").childSelector(new UiSelector().text("Custom View"))‘).click() List