I am testing the user management feature of my app on Rails 5 by cucumber and capybara. In the Users page, all users are listed and there is a "delete" link for each user. I have no idea about clicking the 4th user's delete in this page.
first(:link, "delete").click
I know this line above can select the first "delete", but what about those are not the first or the last?
<%= link_to "delete", user, method: :delete,
data: { confirm: "You sure?" } %>
This is how this link is implemented by erb.
Actually there is another question. As the code above, there is a JavaScript confirm popup after I click "delete". How to click that "OK" button? How do I confirm a javascript popup with Capybara? Answers here do not work.