水豚歧义解析 [英] Capybara Ambiguity Resolution

查看:22
本文介绍了水豚歧义解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决 Capybara 中的歧义?出于某种原因,我需要在页面中使用相同值的链接,但由于出现错误,我无法创建测试

How do I resolve ambiguity in Capybara? For some reason I need links with the same values in a page but I can't create a test since I get the error

Failure/Error: click_link("#tag1")
     Capybara::Ambiguous:
       Ambiguous match, found 2 elements matching link "#tag1"

我之所以无法避免这种情况,是因为设计.我正在尝试使用右侧的推文/标签和页面左侧的标签重新创建 twitter 页面.因此,在同一页面上出现相同的链接页面是不可避免的.

The reason why I can't avoid this is because of the design. I'm trying to recreate the twitter page with tweets/tags on the right and the tags on the left of the page. Therefore it will be inevitable that identical links page shows up on the same page.

推荐答案

我的解决方案是

first(:link, link).click

代替

click_link(link)

这篇关于水豚歧义解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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