如果有两个链接具有相同的元素名称,但位于页面的不同形式上,如何指定一个链接?

发布于 2024-10-11 14:23:32 字数 138 浏览 8 评论 0原文

alt text我的意思是在检查 我的元素我发现这两个链接 名称相同但形式不同。 我想点击第二个链接。 我如何在水中指定这一点?

提前致谢。

alt textWhat I mean that in the inspection of
my element I found that the two links
have the same name but are on different forms.
I want to click the second link.
How could I specify that in water?

Thanks in advance.

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

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

发布评论

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

评论(2

墨小墨 2024-10-18 14:23:32
browser.form(how, what).link(how, what)

如果您提供相关的 HTML,我可以更具体。

browser.form(how, what).link(how, what)

If you provide relevant HTML I can be more specific.

最初的梦 2024-10-18 14:23:32

这两个链接都位于一个 div 内,并带有一些独特的文本。

尽管它们的文本相同,但 href 不同。

这为您提供了两种潜在的方法

1) 如果您知道 href 不会更改,则只需使用该链接来寻址

browser.link(:href, 'javascript:document.poentryform.submit();').click

2) 如果文本不会更改,并且您无法确定 href,则参考它通过外部容器使用正则表达式来匹配已知文本

browser.div(:class => 'screenlet-title-bar', :text => /Purchase Order/).link(:text, 'Continue').click

The two links are each inside a div along with some unique text

Also despite the fact their text is the same the href is different.

This gives you two potential approaches

1) if you know the href won't change, then just address the link using that

browser.link(:href, 'javascript:document.poentryform.submit();').click

2) if the text won't change, and you can't be sure about the href, then refer to it via the outer container using a regular expression to match the known text

browser.div(:class => 'screenlet-title-bar', :text => /Purchase Order/).link(:text, 'Continue').click
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文