Reputation: 129
There are 2 images on a page that have the same image src link. If i use the following code it will click the first image, so how do I click on the second image?
browser.image(:src, "https://itc.mzstatic.com/itc/images/btn-grey-small-edit.png").click
Upvotes: 1
Views: 2761
Reputation: 3685
You need to either capture all images, and click the second one
browser.images(:src, "https://itc.mzstatic.com/itc/images/btn-grey-small-edit.png")[1].click
or specify the index of the image (index starts at 0 for watir-webdriver, or 1 for watir):
browser.image(:src => "https://itc.mzstatic.com/itc/images/btn-grey-small-edit.png", :index => 1).click
Upvotes: 9