How to access an item through another item using Watir?
I have an HTML page as follows:
<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 the image.
This always clicks on the first link:
browser.link(:text, "text").click
+3
2 answers
browser.link(:after?, browser.image(:src, /image/)).click
Sources:
- http://wiki.openqa.org/display/WTR/How+and+What
- http://wiki.openqa.org/display/WTR/Ways+Available+To+Identify+HTML+Tag
- http://wiki.openqa.org/display/WTR/Methods+Supported+by+Element
- http://www.mail-archive.com/wtr-general%40rubyforge.org/msg08829.html
- http://zeljkofilipin.com/2007/05/25/watir-has-a-new-method-after/
+3