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.
ClassName positioning
# Locating unique Elements
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 ()
Xpath positioning
Driver.find_elements_by_xpath ('//android.widget.textview[@resource-id= "Com.mzdk.app:id/item_good_title"]) [1]. 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
method for locating common elements in Appium+python automation-appium