tags:

views:

55

answers:

1

On my page, there are 2 links with the same anchor text.

I am using HtmlUnit to get the link by the anchor text.

The call to:

page.getAnchorByText("1");

Seems to always get the first occurrance, is there a way to get the 2nd occurance if there are 2 links?

A: 

Not using that method. But you can instead call getAnchors() and get a List<HtmlAnchor> -- if you iterate over that and call getTextContent() on each anchor, you can check against whatever string you want and get all of the matches yourself.

Etaoin