appium--element Positioning

Source: Internet
Author: User

First introduce the two positioning elements of the tool, Appium with the Inspector and Android SDK comes with the Uiautomatorviewer1, Uiautomator Viewer is relatively simple, after the simulator opens the app, open it, select

Click this button to sync the emulator or the real-computer interface

Clicking on the element in the page will display some information about the element in the lower right corner.

2, Inspector (Android) use Inspector is more troublesome, first set Appium① first is Android setting

The first time the package and launch activity is not selected items can be empty, fill in application path②general settings check the following two

③ start Appium will find automatically installed APK, and then click on the Appium Search button, pop-up inspector window, click Refresh, refresh the Sync page, in the lower right corner will also display the element information

If an error occurs, check the Appium log for troubleshooting element Positioning method:①by_id

②by_class_name③by_nameIf the control you want to locate has text, you can try by_name directly, or you can use By_name if the text behind it has a value.④by_link_textIf the Herf link tag can be directly attempted with link positioning, but only for WebView, and web Automation is consistent⑤by_xpathFor example, locate the active button

FRAMELAYOUT/LISTVIEW/LINEARLAYOUT/GRIDVIEW/LINEARLAYOUT[1] This is the absolute path XPath XPath can write the first, take advantage of element attributes// Android.widget.textview[contains (@text, ' activity ')] the second kind, basically is to look at the element path, using index//android.widget.listview[0]/ android.widget.linearlayout[0]/android.widget.gridview/android.widget.linearlayout[0]/ Android.widget.TextView layer down analysis, if the same class appears according to index to locate, and the same as the XPath in the Web

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.