Since these nodes don't have ids and text, I have used xpath to find the element but find element fails

I have tried different xpaths as below but none work.

xpath=//*[@class='android.view.View' and @index='11']

I want to find the element

node (11)View[90,1395][990,1575]

These are the failure messages for the xpaths I tried:


INFO : Clicking element 'xpath=//android.view.View[10]'.
FAIL : ValueError: Element locator 'xpath=//android.view.View[10]' did not match any elements.


INFO : Clicking element 'xpath=//android.widget.FrameLayout[1]/android.view.View[10]'.
FAIL : ValueError: Element locator 'xpath=//android.widget.FrameLayout[1]/android.view.View[10]' did not match any elements.

xpath=//*[@class='android.view.View' and @index='11']

INFO : Clicking element 'xpath=//*[@class='android.view.View' and @index='11']'
FAIL : ValueError: Element locator 'xpath=//*[@class='android.view.View' and @index='11']' did not match any elements.

This is the element layout

Element layout

I want to click the element (11)View index[11], to go to the app setting page

want to click the (11)View, index[11], to goto app setting page

I used Robot framework to write the script.

The developers use "React Native" to develop this application. I will try to ask them to add the resource-id or text.

  • It may be easier for someone to help you if you attach the result of Get Source in the question. It'll let us see the state of your application before you try to locate the element.
    – anonygoose
    Commented Feb 13, 2019 at 13:05
  • What language? What does your webdriver declaration look like? Why are you trying to click a view? They are typically just containers. I take it that this is a proprietary app, otherwise please show the screenshot of the element you're trying to click. I'm fairly sure that the enabled triangle icon at the top indicates it's NAF (not accessible-friendly. If this is an in-house app, ask the developers to provide resource-id for automation to make it easier. Commented Feb 14, 2019 at 19:33
  • I used the Robotframework to write the script. The developers use the "React Native" to develop this application. I will try to ask them to add the resource-id or text. Thanks!
    – Brian Pai
    Commented Feb 15, 2019 at 2:05

5 Answers 5


Get your developers to add element ids, finding elements in this fashion is error prone and breaks your tests whenever the app changes in ways that are hard to diagnose and repair quickly. This kind of test code is a testing anti-pattern.

In a nutshell, the time you waste fixing brittle tests is time you could better spend doing exploratory testing that uncovers real product defects, get your developers to help you. It's a team effort.


I'm going to be perfectly honest and say in my 30 years of manual and automated testing I find automating manual test cases for mobile devices a waste of time. The time and $$ involved in creating and maintaining the test suites, considering their relatively short shelf life, is better spent buying a few of the most popular devices and writing comprehensive manual BDD test cases. Or using the emulators built into the browser, particularly if your app is designed for both desktop browsers and mobile devices 'responsive design' takes care of 90% the testing that used to be particular to a mobile device.


you can try to use xpathElement = (xpath of List elements)[index]. Example in your case : xpath=(//android.view.View)[11]


You can use Appium desktop app or Appium Studio app to inspect your app and generate xpath. But as said above - xpath could change from one build to another, so it's not very good solution. Taking into account that you are accessing button at the bottom, maybe even simple coordinates would be better ?


Try the following code:

  • Class Name = android.view.View
  • Index = 11
  • Xpath = //android.view.View[@index='11']


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.