Locating Identical Elements (Java)

Locating Identical Elements (Java)

To differentiate between elements with the same attributes and tag name, you can specify which number element you are referring as shown here:

driver.findElement(By.xpath("(//p[@class='title-white'])[2]"));

This will retrieve the 2nd element on the page with the tag name p and the class title-white.


See Working Example



Using Python

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.