0

I am Trying to automate an android mobile application which has all same attributes i.e. class name,Text,index.

I need to click the second See all button in this screen of the application.

The screen shot using the uiautomator looks as follows:

There is a see All Link which has the same attributes as the second one

How can i find the element using findElement(By.name()) or By xpath??

Muhammad Waleed
  • 2,517
  • 4
  • 27
  • 75
jayath
  • 1
  • 8
  • Possible duplicate of [XPath query to get nth instance of an element](http://stackoverflow.com/questions/4007413/xpath-query-to-get-nth-instance-of-an-element) – arseniyandru Jan 05 '17 at 14:26

1 Answers1

1

It's simple when all attributes has the same name as you say, try to select all elements by findElements(By.className("....")) then add .get(0); for the first and .get(1); for the second this is the logic.

findElements(By.className("....")).get(i); 

i : the index of the element you want

Emna Ayadi
  • 2,430
  • 8
  • 37
  • 77