不起作用的代码:
login_form = page.form_with(:method => 'post')
和有效的代码:
login_form = page.form_with(:method => 'POST')
我通过检查了表单对象puts page.forms.inspect
并得到了
[#<WWW::Mechanize::Form
{name nil}
{method "POST"}
....]
html源码:
<form class="login" method="post"> <fieldset>
<legend>Members Login</legend>
<div>
<label for="auth_username">Username</label> <input id="auth_username" name="auth_username">
</div>
<div>
<label for="auth_password">Password</label> <input id="auth_password" name="auth_password" type="password">
</div>
</fieldset>
<div class="buttons">
<input name="auth_login" type="submit" value="Login"><p class="note"><a href="/forgotpassword">Forgot your password?</a></p>
</div>
</form>
这是错误还是预期行为?