【问题标题】:xpath with multiple contains statements do not function correctly具有多个包含语句的 xpath 无法正常运行
【发布时间】:2014-02-24 09:02:28
【问题描述】:

我有如下的html代码。我正在尝试用硒访问它。如果我做一个

//*[contains(text(),'Add OfficeContract (Portal)')]

它找到了几个(出现更多的html)。所以我想找到一个特定的实例,但是当我尝试时

//*[contains(text(),'Add OfficeContract (Portal)') and contains(text(),'7121995')]

没有找到匹配项。简单的做

//*[contains(text(),'7121995')]

找到各种各样的东西(html 充满了那个字符串)

HTML 代码

<tr class="pd" valign="top"><br>
<td> </td><br>
<td nowrap="">SQAAUTO</td><br>
<td nowrap="">01/30/2014 9:47:48 AM</td><br>
<td><br>
<b>Add OfficeContract (Portal)</b><br>
<br><br>
Office Id 7121995<br>
<br><br>
Contract ID added: "8976504"<br>
<br><br>
Term Date added: "12/31/9999"<br>
<br><br>
</td><br>
</tr>

【问题讨论】:

    标签: xpath contains


    【解决方案1】:

    我认为这里的问题是在同一个元素中找不到两个字符串(根据您的示例)。

    要让上述 xpath 返回结果,您需要这样的元素:

    <b>Add OfficeContract (Portal) 7121995</b>
    

    【讨论】:

      猜你喜欢
      • 2017-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多