我无法点击png图片并遇到错误。
HTML:
<a onmouseover="i2uiSetMenuCoords(this,event)" href="javascript:showMenu('9721')"><img hspace="1" src="./skins/e2-modern/images/dropdown.png" border="0px"></a>
代码:
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);
}
答案 0 :(得分:1)
您的xpath错误...使用以下xpath
//a/img[contains(@src,'/skins/e2-modern/images/dropdown.png')]
希望这可以帮助你...如果它不起作用,请回来
答案 1 :(得分:0)
尝试以下xpath: -
//img[contains(@src,'dropdown.png')]
如果有超过1个满足上述xpath的网页元素,请尝试通过添加额外的属性或父级来使其唯一。
// A / IMG [含有(@src,&#39; dropdown.png&#39)]
// IMG [@hspace =&#39; 1&#39;并包含(@src,&#39; dropdown.png&#39;)]