ID Locator
Methods for ResourceID Properties
driver.find_element_by_id ('com.lizi.app:id/setting_imageview'). Click ()
#以accessibility_id进行定位, for Android, it's the Content-description property.
driver.find_element_by_accessibility_id ('push_button'
ClassName positioning
#
Self.driver.find_element_by_class_name ("android.widget.EditText")
# Find All Android.widget.EditText and locate the first one
Name Locator
#根据name进行定位, for Android, it's the Text property
Driver.find_element_by_name (U" login "). Click ()
Uiautomator positioning
- Method of the Text property
Driver.find_element_by_android_uiautomator ('new Uiselector (). Text ("Custom View")'). Click ()#textDriver.find_element_by_android_uiautomator ('new Uiselector (). Textcontains ("View")'). Click ()#TextcontainsDriver.find_element_by_android_uiautomator ('new Uiselector (). Textstartswith ("Custom")'). Click ()#TextstartswithDriver.find_element_by_android_uiautomator ('new Uiselector (). Textmatches ("^custom.*")'). Click ()#textmatches
- Method of the Class attribute
#ClassName
Driver.find_element_by_android_uiautomator ('new Uiselector (). ClassName ("Android.widget.TextView"). Text ("Custom View"). Click ()
#Classnamematchesdriver.find_element_by_android_uiautomator ('new Uiselector (). Classnamematches (". *textview$"). Text ("Custom View"). Click ()
- Methods for ResourceID Properties
#ResourceId
Driver.find_element_by_android_uiautomator ('new Uiselector (). ResourceId ("Android:id/text1") ')
#Resourceidmatches
Driver.find_element_by_android_uiautomator ('new Uiselector (). Resourceidmatches (". *id/text1$") ')
- Other properties of the element
Driver.find_element_by_android_uiautomator ('new Uiselector (). Clickable (true). Text ("Custom View")'
method for locating common elements in Appium+python automation-appium