tags:

views:

16

answers:

1

Hi just a quicky.

I have to write a Selenium test and I need to get an element by the src as there is no ID for it.

How do I go about doing something like //div[@id='content-inner'] but with @src='../mapshop/images/buy.png' or even better using a contains 'buy.png'?

I've tried testing if the image is there but, selenium.IsElementPresent("//img [@src='../mapshop/images/buy.png']") but that just returns false.

+1  A: 

Found the problem.

Very simple. Needed to specify the full image url not just the src

selenium.IsElementPresent("//img [@src='http://dev.emapsite.com/QA/mapshop/images/edit.png']") returns true.

DazManCat
Interestingly Firefox seems to complain about getting and element by it's src whewre IE handles it perfectly.
DazManCat
Better way to do it is: selenium.Click("//img[contains(@src,'edit.png')]");
DazManCat