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

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

问题描述

如何解决水豚的歧义?由于某些原因,我需要页面中具有相同值的链接,但由于出现错误,所以无法创建测试

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"

之所以无法避免,是因为设计。我正在尝试使用页面右侧的tweets / tags和页面左侧的tags重新创建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天全站免登陆