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.

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

Related Article

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.