jayath
jayath

Reputation: 1

How to click the second element when all the attributes are same for an element on the homepage of the application

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??

Upvotes: 0

Views: 1840

Answers (1)

Emna Ayadi
Emna Ayadi

Reputation: 2460

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

Upvotes: 1

Related Questions