Internet Explorer doesnt handle xpath to locate images exceptionally well

So i have been doing a lot of selenium and the website i am trying to automate test for
doesnt have a lot of element with id, name, or any other HTML attributes that makes selenium testing a bit easier.

So i have been using of xpath, my intent was to click on an image and i have used the src attribute of the image element.

so my original command, (“xpath=//img[@src=“location/of/image/on/disc”]“);

This works excellently on firefox but on IE, i keep getting the error “Element not found!”

so after several tries, this definitely work on both IE and firefox …… (“xpath=//img[@contains(@href, “”)]“);
The second parameter of the xpath “contains” a segment of the link that the image element points to.Note that the img element has a href and that is why i am able to use the “contains” method of the xpath to locate the img.

You Might Also Like
comments powered by Disqus