在视图文件中,我有:
= link_to 'View', post
= link_to 'View', comment
在规范文件中(我使用的是水豚):
click_on 'View'
它点击第一个链接,但我希望它点击第二个.我该怎么做?
在视图文件中,我有:
= link_to 'View', post
= link_to 'View', comment
在规范文件中(我使用的是水豚):
click_on 'View'
它点击第一个链接,但我希望它点击第二个.我该怎么做?
可能有几种方法,但我通常会这样做.
within(".comment") do
click_on("View")
end
也很可能有其他 Select .我通常从cucumber开始进行验收测试,所以我的步骤通常如下
When I follow "View" within the comment element
其中我有一个步骤,将within the comment element
转换为对该步骤本身的范围调用(我认为这是最新的capybara web_步骤中内置的)