Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97804

How to use index number with PageFactory.initElement(driver, this) to identify two identical elements from the DOM?

$
0
0

On a webpage, we are having two links displayed with no other attribute than the link text. I want to make a page object class for a page.

Here the question is how I can specify the WebElement object declaration in page object class which uniquely identified the second instance of the links displayed.

<html>
  <a href="a.html">Link</a>
  <a href="a.html">Link</a>
</html>

for the above (just an example to get the idea), I want to get WebElement object for the second link using PageFactory.initElement(driver, this) statement

@FindBy(how = How.LINK_TEXT, using = "Link")
public static WebElement link;

I think the above will identify the first object only.


Viewing all articles
Browse latest Browse all 97804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>