带有 XPath 的 Selenium IDE 根据其他列识别表中的单元格 [英] Selenium IDE with XPath to identify cell in table based on other column

查看:26
本文介绍了带有 XPath 的 Selenium IDE 根据其他列识别表中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请看下面的html片段:

Please take a look at the snippet of html below:

<tr class="clickable">
<td id="7b8ee8f9-b66f-4fba-83c1-4cf2827130b5" class="clickable">
<a class="editLink" href="#">Single</a>
</td>
<td class="clickable">£14.00</td>
</tr>

当 td[1] 包含Single"时,我试图断言 td[2] 的值.我尝试了以下各种变体:

I'm trying to assert the value of td[2] when td[1] contains "Single". I've tried assorted variants of:

//td[2][(contains(text(),'£14.00'))]/../td[1][(contains(text(),'Single'))]

//td[2][(contains(text(),'£14.00'))]/../td[1][(contains(text(),'Single'))]

我在其他地方成功地使用了类似的符号 - 但在这里无济于事......我认为这取决于 td[1] 具有嵌套元素,但不确定.

I've used similar notation elsewhere successfully - but to no avail here... I think it's down to td[1] having the nested element, but not sure.

有人可以解释我做错了什么吗?:)

Can someone enlighten as to what I'm getting wrong? :)

干杯!

推荐答案

怎么样:

//tr[contains(td[1], "Single")]/td[2]

首先选择包含与文本匹配的,然后选择td[2].

First select the <tr> containing the <td> matching the text, and then select td[2].

那么,

contains(//tr[contains(td[1], "Single")]/td[2], "£14.00")

应该返回True.

或者,更接近您尝试的表达式,您可以测试它是否匹配:

Or, closer to the expression you tried, you could test if this matches:

//tr[contains(td[1], "Single")]/td[2][contains(., "£14.00")]

查看@JensErat 对find xth 的回答td 与 td 包含在相同的 tr xpath python .

See @JensErat's answer to find xth td with td contains in same tr xpath python .

这篇关于带有 XPath 的 Selenium IDE 根据其他列识别表中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆