title: What happens when you click a button using WebRat under cucumber
body: <p>I am trying to login to a Java web application. </p>
  
  <p>The login page has the following html : </p>
  
  <pre><code>  &lt;html&gt;
      &lt;head&gt;&lt;title&gt;Login Page&lt;/title&gt;&lt;/head&gt;
      &lt;body onload='document.f.j_username.focus();'&gt;
        &lt;h3&gt;Login with Username and Password&lt;/h3&gt;
        &lt;form name='f' action='/ui/j_spring_security_check' method='POST'&gt;
         &lt;table&gt;
            &lt;tr&gt;&lt;td&gt;User:&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='j_username' value=''&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type='password' name='j_password'/&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;
               &lt;td&gt;&lt;input type='checkbox' name='_spring_security_remember_me'/&gt; &lt;/td&gt;
               &lt;td&gt;Remember me on this computer.&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="submit" type="submit"/&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="reset" type="reset"/&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;/table&gt;
        &lt;/form&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>
  
  <p>I use the following script:</p>
  
  <pre><code>Given  /^I am logged in as (.*) with password (.*)$/ do | user, password |
    visit "http://localhost:8080/ui"
    click_link "Projects"
    puts "Response Body:"
    puts response.body
    assert_contain "User:"
    fill_in "j_username", :with =&gt; user
    fill_in "j_password", :with =&gt; password
    puts "Response Body:"
    puts response.body
    click_button
    puts "Response Body:"
    puts response.body
  end
  </code></pre>
  
  <p>This gives the following in the log file :</p>
  
  <pre><code>[INFO] Response Body:
  [INFO] &lt;html&gt;&lt;head&gt;&lt;title&gt;Login Page&lt;/title&gt;&lt;/head&gt;&lt;body onload='document.f.j_username.focus();'&gt;
  [INFO] &lt;h3&gt;Login with Username and Password&lt;/h3&gt;&lt;form name='f' action='/ui/j_spring_security_check' method='POST'&gt;
  [INFO]  &lt;table&gt;
  [INFO]     &lt;tr&gt;&lt;td&gt;User:&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='j_username' value=''&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type='password' name='j_password'/&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td&gt;&lt;input type='checkbox' name='_spring_security_remember_me'/&gt;&lt;/td&gt;&lt;td&gt;Remember me on this computer.&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="submit" type="submit"/&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="reset" type="reset"/&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]   &lt;/table&gt;
  [INFO] &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;
  [INFO] Response Body:
  [INFO] &lt;html&gt;&lt;head&gt;&lt;title&gt;Login Page&lt;/title&gt;&lt;/head&gt;&lt;body onload='document.f.j_username.focus();'&gt;
  [INFO] &lt;h3&gt;Login with Username and Password&lt;/h3&gt;&lt;form name='f' action='/ui/j_spring_security_check' method='POST'&gt;
  [INFO]  &lt;table&gt;
  [INFO]     &lt;tr&gt;&lt;td&gt;User:&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='j_username' value=''&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type='password' name='j_password'/&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td&gt;&lt;input type='checkbox' name='_spring_security_remember_me'/&gt;&lt;/td&gt;&lt;td&gt;Remember me on this computer.&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="submit" type="submit"/&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]     &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="reset" type="reset"/&gt;&lt;/td&gt;&lt;/tr&gt;
  [INFO]   &lt;/table&gt;
  [INFO] &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;
  [INFO] Response Body:
  [INFO] 
  [INFO]     Given I am logged in as pti with password ptipti # features/step_definitions/authentication_tests.rb:2
  </code></pre>
  
  <p>So apparently the response.body disappeared after clicking the submit button. I can see from the server log files that the script does not arrive on the Project page.</p>
  
  <p>I am new to webrat and quite new to ruby and I am now thoroughly confused. I have no idea why the response.body is gone. I have no idea where I am. </p>
  
  <p>I speculated that I had to wait for the page request, but all documentation says that webrat nicely waits till all redirects, pageloads, etc are finished. (At least I think I read that).  Besides I find no method to wait for the page in the webrat API.</p>
  
  <p>Can someone give some tips on how to proceed with debugging this?</p>