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