Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 integration testing - Using webrat fill_in not finding fields
    text
    copied!<p>I'm learning testing right now, but am having some issues with Webrat not finding form fields using <code>fill_in</code> even though I've verified it is on the correct page. Does Webrat work off of field names or ID's? I've tried using Ruby symbols and form names to access the field, but neither works in my case. Do you see anything incorrect with my implementation?</p> <p>The error message:</p> <pre><code>5) Forwarding should forward the user to the requested page after signin Failure/Error: integration_sign_in(user) Could not find field: :email </code></pre> <p>The test code:</p> <pre><code>it "should forward the user to the requested page after signin" do user = Factory(:user) visit edit_user_path(user) # The test automatically follows the redirect to the signin page puts current_url integration_sign_in(user) # The test follows the redirect again, this time to users/edit response.should render_template('users/edit') end </code></pre> <p>where <code>integration_sign_in</code> is in the <code>spec_helper.rb</code></p> <pre><code>def integration_sign_in(user) fill_in :email, :with =&gt; user.email fill_in :password, :with =&gt; user.password click_button end </code></pre> <p>The form field HTML:</p> <pre><code>&lt;form action='/sessions' class='mtm' id='sign-in-form' method='post'&gt; &lt;input name='authenticity_token' type='hidden' value='iIIqT6bUwiJkpqpgxm5sjAj3egrNcEgeXPsYmbKQ02U='&gt; &lt;div class='landingSignInForm'&gt; &lt;label class='mas signin-label' for='email'&gt;E-mail:&lt;/label&gt; &lt;input class="mls ras" id="email" name="email" placeholder="e-mail address" type="text" /&gt; &lt;label class='mas signin-label' for='password'&gt;Password:&lt;/label&gt; &lt;input class="mls ras" id="password" name="password" placeholder="password" type="password" /&gt; &lt;input checked='checked' class='mls mtm' name='remember' type='checkbox' value='permanent'&gt; &lt;span class='remember-me-label'&gt;Keep me signed in&lt;/span&gt; &lt;input class='mls mvm ram medium silver button' name='submit' type='submit' value='Sign in'&gt; &lt;a class='forgot-password' href='#'&gt;Forget your password?&lt;/a&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload