ksaitoの日記

日々試したことの覚え書き

httpunitでbuttonをクリックする

移転しました。

自動的にリダイレクトします。

httpunitでbuttonをクリックする

httpunitを使ってFormのsubmitを実行すると戻り値としてWebResponseが返される。

Form form = res.getForms()[0];
WebResponse res = form.submit();

リンクやForm中のButtonをクリックする操作をプログラムから実行する場合、WebResponseが戻されないのでWebConversation.getCurrentPage()で取得する必要がある。

リンク

WebLink link = res.getLinkWith( "response" );
link.click();
WebResponse res = wc.getCurrentPage();

Form中のButton

Button button = form.getButtons()[0];
buttons[i].click();
res = wc.getCurrentPage();