Reputation: 29
I'm trying to locate a tab which is a png image. I have the source of the tab. But I have tried the follwoing options:
1)
WebElement image = driver.findElement(By.id("x", "a"));
String src = image.getAttribute("src");
src.contains("x.png");
2)
WebElement image = driver.findElement(By.name("x"));
I'm unable to do find it.its not a hidden element as well...any inputs???? would be much appreciated...
Upvotes: 1
Views: 3117
Reputation: 2957
Please try this way...
When i have image tags of this type and think id "Size50" is unique
<img id="Size50" src="http://sp2010-sa/talk/harold/Photos/_t/Profile_jpg.jpg"/>
Selenium will search in this way...
WebElement image=Driver.findElement(By.TagName("img")).findElement(By.id("Size50"));
The above code, first searches for all Image Tags and later within Image tags it will search for a Tag with unique ID "Size50".
if the Id "Size50" is unique on the page then we can directly write the following
WebElement image=Driver.findElement(By.id("Size50"));
Upvotes: 1