代码之家  ›  专栏  ›  技术社区  ›  Peter Tillemans

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

  •  1
  • Peter Tillemans  · 技术社区  · 16 年前

    登录页包含以下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>
    

    我使用以下脚本:

    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 => user
      fill_in "j_password", :with => password
      puts "Response Body:"
      puts response.body
      click_button
      puts "Response Body:"
      puts response.body
    end
    

    这将在日志文件中提供以下内容:

    [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
    

    显然,response.body在单击submit按钮后消失了。我可以从服务器日志文件中看到脚本没有到达项目页面。

    我对webrat和ruby都很陌生,现在我完全糊涂了。我不知道为什么尸体不见了。我不知道我在哪里。

    1 回复  |  直到 16 年前
        1
  •  1
  •   Peter Tillemans    16 年前

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

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

    所以我假装重定向通过exliptically访问我期望被重定向的页面,你瞧:它工作了!。