问题
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:
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.
来源:https://stackoverflow.com/questions/3577134/searching-for-an-image-by-src-in-selenium