Selenium:动态单击搜索结果旁边的单选按钮

发布于 2024-09-26 19:27:29 字数 613 浏览 0 评论 0原文

我使用 Selenium 已有一个月了,到目前为止我只使用 IDE。还没有阅读 RC 的奢侈(尽管我会在这个关键项目之后阅读)。无论如何,我想知道如何单击搜索结果旁边的单选按钮,但搜索结果并不总是出现在同一位置。由于我在 Selenium 和编程方面的知识有限,我能想到的最佳解决方案是在结果文本上 veryfyTextPresent,然后使用 xPath 盲目单击文本旁边的几个位置(?这是否可行? )。我怎样才能以不那么原始的方式做到这一点?

因此,在这种情况下,我会验证 Bingo! 然后单击它旁边的单选按钮
O xxxxxxxx
O xxxxxxxx
O xxxxxxxx
宾果游戏!
O xxxxxxxx
O xxxxxxxx

然而,在不同的搜索中,这可能看起来像这样
宾果游戏!
O xxxxxxxx
O xxxxxxxx
O xxxxxxxx
O xxxxxxxx
O xxxxxxxx

无论如何,我希望我已经清楚地解释了我的问题。预先感谢您的所有意见、建议和指导。 :)

I'm a month-old with Selenium and so far all I use is the IDE. Haven't had the luxury of reading on RC (although I will be after this critical project). Anyway I would like to know how I could click the radio button beside a search result w/c does not always appear on the same position. W/ my limited knowledge in Selenium and programming, best solution I can think of is veryfyTextPresent on the text of the result then click blindly a couple of positions beside the text using xPath (? is this even doable ?). How could I do this in a less primitive manner?

So in this scenario I would verify Bingo! then would like to click on the radio button beside it

O xxxxxxxx

O xxxxxxxx

O xxxxxxxx

O Bingo!

O xxxxxxxx

O xxxxxxxx

However on different searches this could look like this

O Bingo!

O xxxxxxxx

O xxxxxxxx

O xxxxxxxx

O xxxxxxxx

O xxxxxxxx

Anyway I hope I've explained my problem clearly. Thanks in advance for all your comments, suggestions and guides. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪花飘飘的天空 2024-10-03 19:27:29

尝试使用 firebug 来研究单选按钮的任何其他区别属性。如果它们确实存在,请使用它们构建 CSS 标识符。如果没有,(如果可能的话),要求开发商添加属性。
或者,尝试在此处发布来自 firebug 的单选按钮的 HTML 标记。

Try using firebug to investigate any additional distinguishing properties for the radio button. If they do exist, use them to construct a CSS identifier. If not, (and if possible), ask the developer to add properties.
Alternately, try posting the HTML tags from firebug for the radio button here..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文