Appium relative position positioning elements----Parent/sibling node positioning

Source: Internet
Author: User
Tags appium
tell me how to locate the parent and sibling nodes when locating elements on the mobile app

Here are two of the most commonly used methods, Other ways to see other chapters of the blog

Instance:

We are now going to navigate to the second element under LinearLayout under relativelayout[0,1285][1080,1465]

One, Use the sibling node to locate the

Usage:
following-sibling:: Find the next node of the current node, that is, the brother node
Preceding-sibling:: Find a node in front of the current node, that is, the brother node

Here I use this sentence to find the element we need to locate:

  xpaht=//android.widdget.textview[@text = "annual yield (History)"]/ FOLLOWING-SIBLING::ANDROID.WIDGET.RELATIVELAYOUT/ANDROID.WIDGET.LINEARLAYOUT[0]/ANDROID.WIDGET.LINEARLAYOUT[1]  

Second, locate through parent node

How to:
Parent:: Or. Find the parent node of the current node

Here's a way to use the parent node to locate the element we need to find:
Xpath =//android.widget.textview[@text = "annual rate of Return (history)"]/parent::android.widget.linearlayout/ ANDROID.WIDGET.RELATIVELAYOUT/ANDROID.WIDGET.LINEARLAYOUT[0]/ANDROID.WIDGET.LINEARLAYOUT[1]

The last sentence can be used. Instead of Parent::

Appium position element relative----parent/sibling node 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.