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

查看:107
本文介绍了带有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] [(包含(text(),'£14.00'))] /../ td [ 1] [(包含(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]

首先选择< tr> 包含< td> 匹配文字,然后选择 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对查找带有td的xth td包含在s中ame 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天全站免登陆