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
Driver.find_element_by_android_uiautomator (' New Uiselector (). ClassName ("Android.widget.TextView"). Text ("Custom View "). Click () #classNamedriver. Find_element_by_android_uiautomator (' New Uiselector (). Classnamematches (". *textview$ "). Text (" Custom View "). Click () #classNameMatches
Pseudo-XPath method positioning
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 () #通过父级元素定位子集元素
Methods for ResourceID Properties
Driver.find_element_by_android_uiautomator (' New Uiselector (). ResourceId ("Android:id/text1") ') # Resourceiddriver.find_element_by_android_uiautomator (' New Uiselector (). Resourceidmatches (". *id/text1$") ') # Resourceidmatches
Methods for description Properties
Driver.find_element_by_android_uiautomator (' New Uiselector (). Description ("Custom View"). Click () # Descriptiondriver.find_element_by_android_uiautomator (' New Uiselector (). Descriptionstartswith ("Custom"). Click () #descriptionStartsWithdriver. Find_element_by_android_uiautomator (' New Uiselector (). Descriptionmatches ("^ Custom.* "). Click () #descriptionMatches
Other properties of the element
In addition to the more commonly used methods above, Uiautomator also supports other methods, such as reducing the scope of the control to be positioned depending on whether the control property can be clicked or not, and the method is not enumerated (checked,clickable,focesed ....... )
"Appium" locates elements according to Uiautomator