4, through the uiautomatorviewer to achieve the Appium element positioning

Source: Internet
Author: User
Tags appium

Small partners who are familiar with selenium automation should know that Webdriver provides eight element positioning methods:

Id
Name
Class name
Tag name
Link text
Partial link text
Xpath
CSS Selector

appium element positioning and webdriver slightly different, specific differences, the following will be described in detail, Before we do this, we open uiautomatorviewer.bat (under the Sdk/tools path)

Appium element Positioning one: locating by Id

As shown in Resource-id is the ID we're looking for.

How to use:

Driver.findelement (By.id ("Com.android.calculator2:id/digit_9"))

appium element Positioning two: by Class Name positioning

There is more than one view used with ClassName , so you should iterate through the views you get, then narrow down the search criteria to get the target control. Not recommended for use

Driver.findelement (By.classname ("Android.widget.Button"));

Appium element Positioning three: positioning via XPath

Find the parent tag class

Driver.findelement (By.xpath ("android.widget.framelayout/android.support.v4.view.viewpager/ Android.widget.Button "))

Appium element positioning four: locating by accessibility ID

This method belongs toAppiumThe location method of the extension. Accessibility IDon Android it is equivalent to contentdescription. This property is handy for some physiological functions that are defective
People using the application. For example, we have aImageViewThere is a color complex picture, perhaps some blindness colour-blind people, can not tell the picture of what is painted. If a user installs a secondary browse tool such asTalkBack, TalkBack will be loud .
Read what the user is currently browsing.TextViewControlTalkBackYou can read the contents directly, butImageView, TalkBackyou can only read the value of contentdescription and tell the user what the picture is.
Since this is a hidden property,Android The various properties used to find controls may be missing or duplicated (such as id duplicates, such as a   list  All the items below may be called
View contentdescriptioncontentdescription  property. It is the element's   content-desc  

/span>

Driver.findelementbyaccessibilityid ("Plus"). Click ();


Appium element Positioning five: positioning via Android Uiautomator

androiduiautomator is a powerful element positioning method, it is through the Android Uiautomator class library to find elements, android uiautomator

4, through the uiautomatorviewer to achieve the Appium element positioning

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.