Appium elements found through the same level (sibling) element

Source: Internet
Author: User
Tags xpath appium

When doing the Appium test case, to get the value of the amount, with uiautomatorviewer to view the element, the element does not have a particularly obvious personality characteristics, the only feature of the positioning is the CONTENT-DESC value, but the value is variable, Therefore, the element cannot be found by its own characteristics. Elements such as:

Since it is not possible to find the element by itself, and found that it cannot be positioned through the previous level of the element, the bottom button "my assets (yuan)" is considered to be special, and certainly can be located, and then see the "my Assets (yuan)" element and the amount element is the same level, This allows the amount element to be found through an XPath sibling relationship as follows:

How to find elements through a sibling relationship, find XPath syntax data, element <E1> preceding some sibling <E2> to meet your needs

According to Xpaht grammar requirements,//E2/PRECEDING-SIBLING::E1, first find E2 and find E1 positioning is E1

E2 positioning is: "//android.view.view[@content-desc= ' my assets (yuan) ']

Because E2 front only E1, all positioning E1 as long as with Android.view.View on it, and finally, can find the exact amount to locate the way:

android.view.view[@content-desc= ' my assets (yuan) ']/preceding-sibling::android.view.view

Appium elements found through the same level (sibling) element

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.