2

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=//android.view.View[10]
xpath=//android.widget.FrameLayout[1]/android.view.View[10]
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:

xpath=//android.view.View[10]

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

xpath=//android.widget.FrameLayout[1]/android.view.View[10]

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 Feb 13 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. – Bill Hileman Feb 14 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 Feb 15 at 2:05
0

Try the following code :

Class Name = android.view.View

Index = 11

Xpath = //android.view.View[@index='11']

driver.findElementByXPath("//android.view.View[@index='11']");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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