Capybara 'fill_in': Ambiguous match for different input names
When you have two inputs, where one contains the name of the other (eg.
Name with special treatment), Capybara's
fill_in method will fail with the following message:
Ambiguous match, found 2 elements matching visible field "Name" that is not disabled (Capybara::Ambiguous)
You can force Capybara to match exactly what you are typing (which makes your tests better anyways) with
name = 'Name' value = 'Bettertest Cucumberbatch' fill_in(field, with: value, match: :prefer_exact)
When using our Spreewald gem, you might want to override the fill-in-step as soon as you encounter the ambiguous matching problem.
# step_definitions/spreewald_overrides.rb # Override to force exact matching for input names When /^(?:|I )fill in "([^"]*)" (?:with|for) "([^"]*)"$/ do |field, value| patiently do fill_in(field, with: value, match: :prefer_exact) end end