method for locating common elements in Appium+python automation-appium

Source: Internet
Author: User
Tags appium

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

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.