简体   繁体   中英

Appium - find element by Xpath

I have one issue which I can't resolve... I'm trying to write automated tests with Appium... We don't have unique elements in our application except Text. As example we have some element which i want to click. This element has not uniquely id "elements" (many of others elements on this page have the same id) but this element has as unique text "Track"... As I know one chance for me it's find this element by Xpath but unfortunately I can't do this and when I run my tests i get one by one exceptions...(

My xpath is:

//*[@id='elements' and contains(text(),'Track']

What I should change in my xpath? how to build it correctly? Thx in advance.

Seems like you have a few mistakes in your XPath, This should work:

//*[@resource-id='elements' and contains(@text,'Track')]

before you go any further with your automation project, visit this site:

http://www.software-testing-tutorials-automation.com/2015/10/ui-automator-viewer-get-android-app.html

driver.findElement(By.xpath("//*[@id='elements' and contains(text(),'Track')]")).clear();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM