あけましておめでとうございます。Mechanize 1.0.0 のお話です。
example.com?xx=yy のようにパラメータのついた URL のページから、action 属性が空のフォーム
<form action="">
を送信すると、パラメータ無しの URL (example.com) に送信されてしまいます。
agent = Mechanize.new agent.get 'http://example.com?xx=yy' agent.form_with(:name => 'foo') do |form| form.click_button # => http://example.com に送信される end
対処法としては、form の action 属性を設定すれば良いです。
agent = Mechanize.new agent.get 'http://example.com?xx=yy' agent.form_with(:name => 'foo') do |form| form.action = 'http://example.com?xx=yy' form.click_button # => http://example.com?xx=yy に送信される end