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,
selenium.click ("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 ......
selenium.click ("xpath=//img[@contains(@href, "google.com")]");
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.
No comments:
Post a Comment