Selenium 如何处理断线<;br/>;使用xpath时
我试图从下面的HTML代码中找到链接(锚定标记Selenium 如何处理断线<;br/>;使用xpath时,selenium,xpath,selenium-webdriver,contains,Selenium,Xpath,Selenium Webdriver,Contains,我试图从下面的HTML代码中找到链接(锚定标记)的xpath 注意:我不想使用绝对xpath,所以我使用xpath的contains()函数 <div class="productList"> <table class="product-listing-table"> <thead> <tr> <th class="product-desc"> <a
)的xpath
注意:我不想使用绝对xpath,所以我使用xpath的contains()
函数
<div class="productList">
<table class="product-listing-table">
<thead>
<tr>
<th class="product-desc">
<a class="pt_sort">Product & Description</a>
</th>
<th>
<a class="pc_sort">
Product
<br/>
Category
</a>
</th>
</tr>
</thead>
</table>
</div>
上面的xpath是有效的
.//th/a[contains(text(),'Product Category')]
这个不行
有人能帮忙吗?试试下面的xpath
"//a[contains(text(),'Product') and contains(.,'Category')]"
此处包含(,'Category')检查给定标记的任何子标记的内部文本它给出了什么错误?注意这里没有链接,只有锚。链接将由
href
属性提供。
"//a[contains(text(),'Product') and contains(.,'Category')]"