1. 程式人生 > >appium python中的android uiautomator定位

appium python中的android uiautomator定位

通過 ppi custom name src ima parent bili mat

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() 技術分享圖片

appium python中的android uiautomator定位