gpt4 book ai didi

xpath - Selenium IDE 和 xpath - 在表中查找文本/行并选择单选框

转载 作者:行者123 更新时间:2023-12-03 15:48:13 25 4
gpt4 key购买 nike

我一直在使用 Selenium IDE 并获得了一些不错的结果。我已经阅读了大量有关 following-sibling 和 preceding-sibling 的资料,但我找不到正确的单选按钮。

本质上,我想在表格中找到包含“测试”一词的行,然后单击单元格中的单选按钮。

到目前为止我可以找到输入按钮 //输入[@type='radio']

并找到文本测试 //a[包含(文本(),'测试')]

我一直在尝试在ide中使用它

check | //input[@type='radio']/following-sibling::td[1]/a[contains(text(),'testing')]

但我收到错误 [error] locator not found://input[@type='radio']/following-sibling::a[contains(text()[1],'testing') ]

非常感谢任何帮助改变这一点的人:)

干杯

达米安

这是基本表......

<tbody id="list">
<tr>
<th>
<label class="radio">
<input class="presentation_radio" type="radio" value="1" name="presentation_radio">
</label>
</th>
<td>
<a href="/link_to/document">testing </a>
</td>
<td>testing</td>
<td>Joe Acme</td>
<td>Presentation</td>
<td>03 May 2012</td>
<td>5 (1)</td>
</tr>
</tbody>

最佳答案

你的 xpath 的问题是 tdinput 不是 sibling (他们没有共同的父级),即使你将您的 xpath 更改为更正确的版本:

//input[@type='radio']/following::td[1]/a[contains(text(),'testing')]

它会找到前面有复选框而不是复选框本身的 a。所以正确的 xpath 将是:

//a[contains(text(),'testing')]/preceding::input[@type='radio'][1]

//tr[descendant::a[contains(.,'testing')]]//input[@type='radio']

对于 xpath 轴教程,请阅读:http://msdn.microsoft.com/en-us/library/ms256456.aspx

关于xpath - Selenium IDE 和 xpath - 在表中查找文本/行并选择单选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10428878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com