02.06.07

Watir: Select Element Using Multiple Attributes

Posted in Watir at 2:21 pm by Željko Filipin

There are two links in a page that I am testing.

I need to get value of href attribute for the second link.

I can not use :text, because it will return href attribute for the first link.

I can use :index, but if anything on that page changes, it could break.

Bret Pettichord posted posted a solution for this at wtr-general a few months ago.

In 1.5, this syntax works:

This will find the second div with the name ‘foo’.

Not all elements yet have multiple attribute support.

And it really works.

Leave a Comment