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

前端 未结 7 874
北海茫月
北海茫月 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:28

    This works for me if you have several rows of identical classes and you want to find the second row. Like a previous author mentioned, capybara indexing starts at 1.

    within all(".trip-row")[2] do
       assert page.has_content?("content")
    end
    
    0 讨论(0)
提交回复
热议问题