Filipin.eu

Željko Filipin's blog.
Home Blog Tags License

View on GitHub
25 May 2007

Watir Has A New Method: after?

by Željko Filipin

Imagine that you have two links. Both links are the same.

<a>text</a>

The only thing that makes them different is that the second one is located after an image.

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

Of course, you just have to click the second link. You have already tried this.

browser.link(:text, "text").click

But, it always clicks the first link. There is a way.

browser.link(:after?, browser.image(:src, /image/)).click

This is so cool.

You will need Watir 1.5. Bret Pettichord posted that at wtr-general.

tags: code - ruby