我试图让Selenium单击基于子图像元素的父web元素。下面是我在页面源代码中使用的元素的片段:
<a id="_20_ivtm" href="https://foobar:443/web/baz/document-library?fedit_file_entry">
<img id="aui_3_2_0_1724" class="icon" style="background-image: url('/foobar/images/document_library/_sprite.png'); background-position: 50% -16px; background-repeat: no-repeat; height: 16px; width: 16px;" alt="" src="/foobar/images/spacer.png"/>
Add Document我希望单击基于其子映像元素中的"Add Document“子文本的a父元素。我正在用Java编写代码。对于如何最好地做到这一点,有什么建议吗?
发布于 2015-01-05 18:27:01
文本与<img>标记无关,它与<a>标记相关。你可以找到这样的情况:
driver.findElement(By.xpath("//a[contains(., 'Add Document')]"));https://stackoverflow.com/questions/27785351
复制相似问题