Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 如何处理断线<;br/>;使用xpath时_Selenium_Xpath_Selenium Webdriver_Contains - Fatal编程技术网

Selenium 如何处理断线<;br/>;使用xpath时

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

我试图从下面的HTML代码中找到链接(锚定标记
)的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')]"