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>
次のスクリプトを使用します。
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が消えました。サーバー ログ ファイルから、スクリプトが [プロジェクト] ページに届かないことがわかります。
私はwebratが初めてで、rubyもまったく初めてで、完全に混乱しています。response.body がなくなった理由がわかりません。私は自分がどこにいるのかわからない。
ページリクエストを待たなければならないと推測しましたが、すべてのドキュメントによると、webrat はすべてのリダイレクト、ページロードなどが完了するまで適切に待機します。(少なくとも私はそれを読んだと思います)。その上、webrat API でページを待機する方法が見つかりません。
誰かがこれをデバッグする方法についていくつかのヒントを与えることができますか?