This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 3
May 2018

I have an element with an ID, but - That ID is not unique. More elements have the same ID.
I would like to tap on the first 3 out of the whole, How do I do that?

I have a previous practice with: driver.findElementByXPath(“(//Class_Name) [i]”);,
That way I can choose an ‘i’ element when several exist with the same className.

I tried manipulating this syntax with a ‘recourse-id’, but with no success.
Please advice?

  • created

    May '18
  • last reply

    Jul '18
  • 2

    replies

  • 252

    views

  • 3

    users

  • 1

    like

  • 1

    link

When you have an ID on your element, you can search like this, using “findElements()”:

driver.findElements(By.id(“your_id”)).get(index);

1 month later

Thanks @MrZigaS.
I’ll leave here my implementation using POM in case someone will need it.

Element:
@AndroidFindBy(id = “spinner_edittext”)
public List dropDownList;

test case:
myProfile.dropDownList.get(1).click();