John
John

Reputation: 63

Protractor more than one element found for locator By(css selector, .image-holder) - the first result will be used

How would I be able to reference by index? I am trying to write automated tests to test an Angular 6 website.

element.all(by.css(".image-holder")).click();

Thanks in advance

Upvotes: 3

Views: 1514

Answers (2)

Ragavan Rajan
Ragavan Rajan

Reputation: 4397

You can try identifying the tags by id

 const div = element.querySelectorAll('div')[0];

Upvotes: 0

John
John

Reputation: 63

Don't worry managed to solve the problem

Here's the code for future reference:

element.all(by.css(".image-holder")).get(0).click();

Upvotes: 1

Related Questions