Android - Find menu item from modal screen

Hi. If I have an modal screen with a menu (please check the screenshots), how can I find an item from the menu to tap on it? If I try driver.elementsByXPath("//android.widget.TextView") the last element is “Contul meu”

Appium 1.6, react-native app, android platform

Build an unique xpath for the target menu item.

I don’t know how’s your app’s DOM but the sentence must look like something like that:

Notice that I’m using findElement instead findElements.

It’s an mobile app and my test is written in javascript (node.js), but I tried your version like this



return driver.findElement(wd.By.xpath("//android.widget.TextView[@text=‘Logout’]")), where wd is a WebDriver/Selenium 2 node.js client

but does not work

see in “driver.getPageSource()” -> if you cannot find there your text = you can’t do anything

BTW i see that menu text is like: ‘Ä’ - be careful with it cause it can be other actually.

Ok. I will try. Thanks

Wow, I assumed it was java-client, sorry then.

@Aleksei is right, just check the page source and build an xpath to uniquely locate the target node. If you cannot find your text you may take advantage from the front-design of your app:

  • May exists more attributes that allow you to identify that node.
  • May build a more complex xpath expression to associate the target node to another identifiable node.
  • May identify a parent node that is wrapping the target textview and can tap on it with the same practical effects…
  • Any of the previous scenarios.

Appium is just a tool. The location strategy is on the programmer’s hand.


Yeah, you are absolutely right. It didn’t found my element because of an empty space before the text :smiley: Thanks guys.