Searching for an image by src in Selenium

帅比萌擦擦* 提交于 2019-12-24 17:28:03

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!