当您在cucumber下使用WebRat单击按钮时会发生什么

当您在cucumber下使用WebRat单击按钮时会发生什么,cucumber,webrat,Cucumber,Webrat,我正在尝试登录到Java web应用程序 登录页面包含以下html: <html> <head><title>Login Page</title></head> <body onload='document.f.j_username.focus();'> <h3>Login with Username and Password</h3> <form n

我正在尝试登录到Java web应用程序

登录页面包含以下html:

  <html>
    <head><title>Login Page</title></head>
    <body onload='document.f.j_username.focus();'>
      <h3>Login with Username and Password</h3>
      <form name='f' action='/ui/j_spring_security_check' method='POST'>
       <table>
          <tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr>
          <tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr>
          <tr>
             <td><input type='checkbox' name='_spring_security_remember_me'/> </td>
             <td>Remember me on this computer.</td>
          </tr>
          <tr><td colspan='2'><input name="submit" type="submit"/></td></tr>
          <tr><td colspan='2'><input name="reset" type="reset"/></td></tr>
        </table>
      </form>
    </body>
  </html>
这将在日志文件中提供以下内容:

[INFO] Response Body:
[INFO] <html><head><title>Login Page</title></head><body onload='document.f.j_username.focus();'>
[INFO] <h3>Login with Username and Password</h3><form name='f' action='/ui/j_spring_security_check' method='POST'>
[INFO]  <table>
[INFO]     <tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr>
[INFO]     <tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr>
[INFO]     <tr><td><input type='checkbox' name='_spring_security_remember_me'/></td><td>Remember me on this computer.</td></tr>
[INFO]     <tr><td colspan='2'><input name="submit" type="submit"/></td></tr>
[INFO]     <tr><td colspan='2'><input name="reset" type="reset"/></td></tr>
[INFO]   </table>
[INFO] </form></body></html>
[INFO] Response Body:
[INFO] <html><head><title>Login Page</title></head><body onload='document.f.j_username.focus();'>
[INFO] <h3>Login with Username and Password</h3><form name='f' action='/ui/j_spring_security_check' method='POST'>
[INFO]  <table>
[INFO]     <tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr>
[INFO]     <tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr>
[INFO]     <tr><td><input type='checkbox' name='_spring_security_remember_me'/></td><td>Remember me on this computer.</td></tr>
[INFO]     <tr><td colspan='2'><input name="submit" type="submit"/></td></tr>
[INFO]     <tr><td colspan='2'><input name="reset" type="reset"/></td></tr>
[INFO]   </table>
[INFO] </form></body></html>
[INFO] Response Body:
[INFO] 
[INFO]     Given I am logged in as pti with password ptipti # features/step_definitions/authentication_tests.rb:2
[INFO]响应主体:
[信息]登录页面
[信息]使用用户名和密码登录
[信息]
[信息]用户:
[信息]密码:
[信息]在这台计算机上记住我。
[信息]
[信息]
[信息]
[信息]
[信息]答复机构:
[信息]登录页面
[信息]使用用户名和密码登录
[信息]
[信息]用户:
[信息]密码:
[信息]在这台计算机上记住我。
[信息]
[信息]
[信息]
[信息]
[信息]答复机构:
[信息]
[信息]鉴于我是以pti身份登录的,密码为pti#功能/步骤定义/身份验证#测试。rb:2
显然,在点击提交按钮后,response.body消失了。我可以从服务器日志文件中看到脚本没有到达项目页面

我是webrat的新手,也是ruby的新手,现在我完全糊涂了。我不知道为什么尸体不见了。我不知道我在哪里

我推测我必须等待页面请求,但所有文档都说webrat会很好地等待所有重定向、页面加载等完成。(至少我觉得我读到了)。此外,我在webratapi中找不到等待页面的方法


有人能给出一些关于如何继续调试的提示吗?

我确认了使用原生ruby排除任何jruby或JVM相关问题的行为

我将webrat重新配置为使用Selenium,这样我就可以看到发生了什么

登录后发生了302重定向。selenium实现遵循重定向,但mechanize实现不遵循重定向。所以我解释了重定向消息的主体,它当然是空的


因此,我假装重定向,无意中访问了我希望重定向的页面,瞧,它成功了

我确认了使用原生ruby排除任何jruby或JVM相关问题的行为

我将webrat重新配置为使用Selenium,这样我就可以看到发生了什么

登录后发生了302重定向。selenium实现遵循重定向,但mechanize实现不遵循重定向。所以我解释了重定向消息的主体,它当然是空的


因此,我假装重定向,无意中访问了我希望重定向的页面,瞧,它成功了

似乎您在表单上同时有一个“提交”和一个“重置”按钮。也许Webrat不知道该按哪个按钮?是的,。。。但这只会将字段的值重置为原始值。。。我被难住了。。。。我会让周末完成它的工作,并在周一重新访问它。似乎你在表单上有一个“提交”和一个“重置”按钮。也许Webrat不知道该按哪个按钮?是的,。。。但这只会将字段的值重置为原始值。。。我被难住了。。。。我会让周末做它的工作,周一再去看它。
[INFO] Response Body:
[INFO] <html><head><title>Login Page</title></head><body onload='document.f.j_username.focus();'>
[INFO] <h3>Login with Username and Password</h3><form name='f' action='/ui/j_spring_security_check' method='POST'>
[INFO]  <table>
[INFO]     <tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr>
[INFO]     <tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr>
[INFO]     <tr><td><input type='checkbox' name='_spring_security_remember_me'/></td><td>Remember me on this computer.</td></tr>
[INFO]     <tr><td colspan='2'><input name="submit" type="submit"/></td></tr>
[INFO]     <tr><td colspan='2'><input name="reset" type="reset"/></td></tr>
[INFO]   </table>
[INFO] </form></body></html>
[INFO] Response Body:
[INFO] <html><head><title>Login Page</title></head><body onload='document.f.j_username.focus();'>
[INFO] <h3>Login with Username and Password</h3><form name='f' action='/ui/j_spring_security_check' method='POST'>
[INFO]  <table>
[INFO]     <tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr>
[INFO]     <tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr>
[INFO]     <tr><td><input type='checkbox' name='_spring_security_remember_me'/></td><td>Remember me on this computer.</td></tr>
[INFO]     <tr><td colspan='2'><input name="submit" type="submit"/></td></tr>
[INFO]     <tr><td colspan='2'><input name="reset" type="reset"/></td></tr>
[INFO]   </table>
[INFO] </form></body></html>
[INFO] Response Body:
[INFO] 
[INFO]     Given I am logged in as pti with password ptipti # features/step_definitions/authentication_tests.rb:2