Say in front
1, https://github.com/appium/python-client/tree/master/test inside some test, you can see, research and research
2, learn to use Uiautomatorviewer and Hierarchyviewer, these two tools can help to view the app some information, very useful, under the Android-tools
The control's characteristics are the properties of the control, so we can locate it based on the characteristics of the control
PS: After the assertion section
1, find_elements_by_accessibility_id, to accessibility_id for positioning, for Android, is the Content-description attribute ( Use Uiautomatorviewer to see), so the parameters are not mistaken
el = self.driver.find_element_by_accessibility_id (u' Please enter QQ number or phone or email '# Take the QQ login page as an example = self.driver.find_elements_by_accessibility_id (' Please enter QQ number or phone or email ') ) self.assertisinstance (Els, list)
2, Find_element_by_class_name, according to class to locate
Self.driver.find_element_by_class_name ("android.widget.EditText") # Locate unique element Self.driver.find_elements_by_class_name ("android.widget.EditText") [0 ] # Find all android.widget.EditText and locate the first one
3, Find_elemnt_by_name, according to the name of the location, for Android, is the Text property
E3 = Self.driver.find_element_by_name (u" login ")
4, Find_element_by_android_uiautomator, using uiautomator positioning, the following parameters can be changed
Uiselector (). Text is positioned according to the Text property
Self.driver.find_element_by_android_uiautomator ('new Uiselector (). Text ("33001122")')
Uiselector.textcontains fuzzy positioning based on the Text property
E6 = Self.driver.find_element_by_android_uiautomator ('new Uiselector (). Textcontains ("1122") ')
Uiselector.textstartswith according to the text of the previous several whether or not consistent with text to locate
E7 = Self.driver.find_element_by_android_uiautomator ('new Uiselector (). Textstartswith ("") ')
The uiselector.textmatches is positioned by regular expressions and text, but not so much, but not in the first place.
Uiselector.classname uses class to locate and use hierarchical positioning, such as finding all the edittext and then positioning it according to text
E8 = Self.driver.find_element_by_android_uiautomator ('new Uiselector () ' . ClassName ("Android.widget.EditText") ' ' . Textcontains (" the") ')
Uiselector.classnamematches is positioned using regular expressions and class.
And Uiselector.descriptionmatches, Uiselector.descriptionstartwith, Uiselector.description.
5, driver.find_element_by_id and Uiseletor.resourceid are through the resourceId to locate, this property only in the API Level18 above only
E9 = Self.driver.find_element_by_android_uiautomator ('new Uiseletor () ' . ResourceId ' ' ("Com.taobao.qianniu:id/accountcompletetextview") ' = self.driver.find_element_by_id ("Com.taobao.qianniu:id/accountcompletetextview ")
--------If there is any problem, please buckle me in time! Thanksgiving!
--------will not be updated regularly, please explain the original
Appium + Python-------------element positioning