Can't press SELENIUM JAVA image selector
I can't click on the png image and come across an error.
HTML:
<a onmouseover="i2uiSetMenuCoords(this,event)" href="javascript:showMenu('9721')"><img hspace="1" src="./skins/e2-modern/images/dropdown.png" border="0px"></a>
code:
if (navigateToDetails) {
SearchListSelectorExt selector = new SearchListSelectorExt();
//switchToFrame(getFrames(FRAME_TYPE.rcp_content));
//switchToFrame(getHeaderFrames());
WebElement element= selector.get(By.xpath("//a[contains(@src,'./skins/e2-modern/images/dropdown.png'"));
Object value = selector.getElementValue(element);
systemDocID = value.toString();
selector.clickName(systemDocID);
//selector.clickName(CustomerItem);
}
+3
source to share
2 answers
Try to give xpath: -
//img[contains(@src,'dropdown.png')]
- Here we are directly looking for the img tag, so its src attribute contains the text dropdown.png.
-
If there are more than 1 web element satisfying above xpath, try to make it unique by adding additional attributes or parent.
// a / img [contains (@ ccc 'dropdown.png')]
// img [@hspace = '1' and contains (@src, 'dropdown.png')]
0
source to share