Posted about 1 month ago. Visible to the public.

Handling duplicate links with Capybara and Cucumber

Sometimes, you might have duplicate links on a page. Trying to click those links will by default cause Capybara to raise an Ambiguous match error.

If you do not care about which of those links are clicked, you can disable this errors by adding the following meta step:

Copy
When(/^(.*) \[allow ambiguous\]$/)do |step_text| prior_match_strategy = Capybara.match Capybara.match = :first step(step_text) ensure Capybara.exact = prior_match_strategy end

Use it with

Copy
When I follow "a duplicate link" [allow ambiguous]

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Tobias Kraze
Last edit:
about 14 hours ago
by Judith Roth
Keywords:
match, prefer, exact
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more