How to click on the second link with the same text using Capybara in Rails 3?

前端 未结 7 878
北海茫月
北海茫月 2020-12-24 11:25

In a view file I have:

= link_to \'View\', post
= link_to \'View\', comment

In a spec file (I\'m using Capybara):

click_on          


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-24 12:16

    For capybara 2 solution:

    within(".comment") do
      click_on("View")
    end
    

    would not help if you have a few .comment. So simple use: page.first(:link, "View").click

提交回复
热议问题