"Appium" locates elements according to Uiautomator

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.