I have two forms (a sign-up and sign-in) in one html file which I am testing using Capybara's fill_in syntax. However both have a username field and both have a password field and I'm getting Ambiguous match, found 2 elements matching field :username . How can I, in my spec helper methods ensure I'm filling in the field of the correct form. I would imagine I need to id= each form but I can't find anywhere that has a capybara syntax for that.
My html
<form id="signUpForm"action='/user' method="post">
<!-- more fields -->
<input class="entryField" type="text" name="username" required>
<input class="entryField" type="password" name="password" required>
<!-- more fields -->
<input type="submit" value="Sign up">
</form>
<form id="signInForm" action="/session" method="post">
<input class="entryField" type="text" name="username" placeholder="Username">
<input class="entryField" type="password" name="password" placeholder="Password">
<input type="submit" value="Sign in">
</form>
And my helper method
def sign_in user
visit '/'
fill_in :username, with: user.username
fill_in :password, with: user.password
click_button 'Sign in'
end
Aucun commentaire:
Enregistrer un commentaire