I have this code in my page
<div>
<label for="user_password">Heslo</label>
<br />
<input id="user_password" name="user[password]" size="30" type="password">
</div>
<div>
<label for="user_password_confirmation">Heslo pro kontrolu</label>
<br>
<input id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password">
</div>
And I would like to use these steps in Cucumber:
And I fill in "Heslo" with "NeznameHeslo328"
And I fill in "Heslo pro konrolu" with "NeznameHeslo328"
Step definition is simple:
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |name, text|
fill_in(name, :with => text)
end
BUT Capybara raises Ambiguous match, found 2 elements matching field "Heslo" (Capybara::Ambiguous) for first step.
When I change name in label with for="user_password_confirmation"
to "Hesla pro kontrolu" (and second step accordingly), everything is OK.
Is there any way to force Capybara to match exact phrase within label? Without using css selectors in scenario.