在 Selenium WebDriver 中,如何使用 XPath 表达式来定位下面 HTML 中的链接文本 ("Add New Button")?
<a href="SOME URL">
<span >
<i class=""/>
</span>Add New Button
</a>
我尝试了以下检查元素的方法,但都没有成功。
//a[text()='Add New Button']
//a[contains(text(),'Add New Button']
//a/span/i[text()='Add New Button']
//a/span/i[contains(text(),'Add New Button']
我知道第3和第4个不行,但我还是试了试。
那么,在这样的HTML DOM中,如何使用XPath根据链接文本找到链接呢?