Summary of positioning method for mobile automation ==>appium

Source: Internet
Author: User
Tags xpath appium

1. ID

Android

Android's Resource-id corresponds to the ID positioning method, which can be obtained by index to get the desired element (starting from 0 to find the same name Resource-id attribute in the DOM tree). When using Appium-desktop to get an element, the ID and Resource-id are the same, if there is only Resource-id, there may be a repetition, if you are prompted to locate the ID, you can only receive, represent the unique.

driver.find_element_by_id ('com.tencent.mobileqq:id/btn_login')

2, Accessibilityid

Android

The Content-desc property of Android corresponds to the Accessibilityid positioning method, this CONTENT-DESC attribute is specifically set for people with disabilities and is recommended if this property is not empty.

driver.find_element_by_accessibility_id (' Please enter QQ number or phone or email ')

Ios

Both the label and name properties of iOS correspond to the Accessibilityid positioning method, which is recommended if available.

3. Xpath

Android

The XPath positioning of Android is much the same as the XPath location of the PC, which can be positioned by relative path positioning method. The difference is that the relative path location of the//after only can be connected to the Android class properties or *.

Driver.find_element_by_xpath ('//android.widget.edittext[@text = "QQ number/Mobile number/email"])

Ios

IOS10 after using the Xcuitest framework, the native framework does not support xpath,appium conversion, and is not recommended for slow speed.

4, Uiautomator

Android's source test framework for positioning, positioning speed fast. It is recommended to use several commonly used.

1 #at runtime, this is called the Uiautomator API of the Android-brought UI framework .2 #introduce several simple and common, text, className, Resource-id3 #text4 #match all text text5Driver.find_element_by_android_uiautomator ('new Uiselector (). Text ("phone number")')6 #contain text text7Driver.find_element_by_android_uiautomator ('new Uiselector (). Textcontains ("machine")')8 #start with text What9Driver.find_element_by_android_uiautomator ('new Uiselector (). Textstartswith ("Hand")')Ten #Regular Match Text OneDriver.find_element_by_android_uiautomator ('new Uiselector (). Textmatches ("^ Hand. *")') A   - #ClassName -Driver.find_elements_by_android_uiautomator ('new Uiselector (). ClassName ("Android.widget.TextView")') the #classnamematches -Driver.find_elements_by_android_uiautomator ('new Uiselector (). Classnamematches ("^android.widget.*")') -   - #Resource-id, Resourceidmatches +Driver.find_element_by_android_uiautomator ('new Uiselector (). ResourceId ("Com.syqy.wecash:id/et_content")') -   + #Description ADriver.find_element_by_android_uiautomator ('new Uiselector (). Description ("S Calendar")') at #Descriptionstartswith -Driver.find_element_by_android_uiautomator ('new Uiselector (). Descriptionstartswith ("Calendar")') - #descriptionmatches -Driver.find_element_by_android_uiautomator ('new Uiselector (). Descriptionmatches (". * Calendar $")')

5, Iospredicatestring

Support for more than iOS10, can be multiple properties simultaneously location, recommended. (Alternative XPath)

Driver.find_elements_by_ios_predicate ("label = = ' Login') driver.find_elements_by_ios _predicate ("type= ' xcuielementtypeother ' and name= ' contacts, tags, 2nd buttons, total 3")

6, Iosuiautomation

iOS9.3 used below, now obsolete, iospredicatestring instead of iosuiautomation

Mobile Automation ==>appium Positioning Method Summary

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.