views:

288

answers:

2

I have a page with HTML like this:

<a>text</a>
<img src="image.png" />
<a>text</a>

I would like to click the second link. Links have completely identical attributes. The only thing that is different is that the second link is after an image.

This always clicks the first link:

browser.link(:text, "text").click
+1  A: 

You can also do:

browser.link(:text=>"text",:index=>2)

In general, you can include any combination of conditions via a ruby hash.

Meir