smiley
smiley

Reputation: 11

how to identify path for android using appium

This is for iOS to find all the elements:

driver.findElementsByXPath("//UIAApplication[1]/UIAWindow[1]/UIACollectionView[1]/UIACollectionCell"); 

I need the similar path for android, I tried:

driver.findElementsByXPath("//android.view.View[1]/android.widget.GridView[1]") 

But it's not working. Please help

Upvotes: 0

Views: 884

Answers (3)

Abhishek Swain
Abhishek Swain

Reputation: 1054

Please post the log from Appium console, so that we will be able to find out the exact issue.

From :

//android.view.View[1]/android.widget.GridView[1]

It seems there are multiple GridViews are available on that particular screen. Please try to put some constraints.

e.g

//android.view.View[@id='Id_of_the_View']/android.widget.GridView[@something here too]

Upvotes: 1

Maria
Maria

Reputation: 107

If you are using Eclipse as editor, then you can open an emulator where you have the app installed, then open DDMS perspective from Eclipse.

Go into your app at the view you want to inspect, and then click the button Dump View Hierarchy for UI Automator in the DDMS perspective.

This will give you a snapshot and you can hover over elements and find their properties.

Upvotes: 0

SthQA
SthQA

Reputation: 399

If you are on a native application, just use the inspector or hierarchy viewer to get the Xpath but I would advise you use driver.findElement(s)ById to get specific elements. Hope this helps.

If you could give a bit more detail maybe I could help.

Upvotes: 0

Related Questions