4

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 '19 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 '19 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 '19 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']");
|improve this answer|||||
0

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.

|improve this answer|||||

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.