Reputation: 547
For instance, if the link contains an <image>
element as the text, then how do we access it using the watir:
For example:
<a><img src="" alt=""\></a>
So now I want to access the link using ("text-attribute") then how do we do these?
Upvotes: 2
Views: 2410
Reputation: 46826
You could locate the image and then get the parent element:
browser.image(:alt => "").parent.click
Or you could find a link that contains the image:
browser.links.find{ |a| a.image(:alt => "").exists? }.click
If you really want to use the text, then you can use a :text => ''
. The text locator only checks the visible text of the link - ie it ignores the image.
browser.link(:text => '').click
Upvotes: 2