Summary of Appium positioning method

Source: Internet
Author: User
Tags xpath appium

Locating elements by Appium-desktop

ClassName

Android

The class property of Android corresponds to the ClassName positioning method, ClassName is usually repeated, you can get the desired element by index. (Find the same name Class attribute in the DOM tree starting from 0)

Ios

The Type property of iOS corresponds to the ClassName positioning method, ClassName is generally duplicated, and the desired element can be obtained by index. (Find the same name Class attribute in the DOM tree starting from 0)

Id

Android

Android's Resource-id corresponds to the ID location, this ID can also be duplicated, you can use index to get the required elements. (Find the Resource-id attribute with the same name in the DOM tree starting from 0)

When you use Appium-desktop to get an element, if you are prompted to locate the ID, you can only receive it, representing the unique.

Xpath

Android

The XPath positioning of Android and the XPath location of the PC is much the same, can be positioned by relative path positioning, the difference is that the relative path is located in the//after only the class properties of Android or * can be connected. (//android.widget.button[@text = "Login"])

Ios

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

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.

Ios

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

Androiduiautomator

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

Open method:

#at runtime, this is called the Uiautomator API of the Android-brought UI framework .#introduce several simple and common, text, className, Resource-id#text#match all text textDriver.find_element_by_android_uiautomator ('new Uiselector (). Text ("phone number")')#contain text textDriver.find_element_by_android_uiautomator ('new Uiselector (). Textcontains ("machine")')#start with text WhatDriver.find_element_by_android_uiautomator ('new Uiselector (). Textstartswith ("Hand")')#Regular Match TextDriver.find_element_by_android_uiautomator ('new Uiselector (). Textmatches ("^ Hand. *")') #ClassNameDriver.find_elements_by_android_uiautomator ('new Uiselector (). ClassName ("Android.widget.TextView")')#classnamematchesDriver.find_elements_by_android_uiautomator ('new Uiselector (). Classnamematches ("^android.widget.*")') #Resource-id, ResourceidmatchesLike our HTML ID this could be repeated,
Driver.find_element_by_android_uiautomator ('new Uiselector (). ResourceId ("Com.syqy.wecash:id/et_content")') #DescriptionDriver.find_element_by_android_uiautomator ('new Uiselector (). Description ("S Calendar")') #DescriptionstartswithDriver.find_element_by_android_uiautomator ('new Uiselector (). Descriptionstartswith ("Calendar")') #descriptionmatchesDriver.find_element_by_android_uiautomator ('new Uiselector (). Descriptionmatches (". * Calendar $")')

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")

Iosuiautomation

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

Summary of Appium positioning method

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.