htmlunit でフォーラム phpbb3 をテストしています。フォーラム phpbb のトピックへのメッセージの自動追加に問題があります。非表示の入力を投稿する必要があります: form_token と creation_time。どうすれば入手できますか?
final WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_7);
HtmlPage page = webClient.getPage(URL);
// get input "username"
final HtmlElement user_name = page.getElementsByName("username").get(0);
//enter of value
user_name.type(par[0]);
//get input "password"
final HtmlElement password = page.getElementsByName("password").get(0);
//enter of value
password.type(par[1]);
// get button 'login' and click
final HtmlSubmitInput submit_button = page.getElementByName("login");
page = submit_button.click();
//Go to the page of adding message
page=page.getAnchorByText("Your first forum").click();
page=page.getAnchorByText("Welcome to phpBB3").click();
page=page.getAnchorByHref("./posting.php?mode=reply&f=2&t=1").click();
//get textarea
final HtmlTextArea myMessage=page.getElementByName("message");
/* HtmlInput form_token=page.getElementByName("form_token");
form_token.setAttribute("value", "0");
HtmlInput creation_time=page.getElementByName("creation_time");
creation_time.setAttribute("value", "0");
*/
//enter the valye
myMessage.type("myText");
//get the button 'Submit' and click
final HtmlElement submit_post = page.getElementByName("post");
page=submit_post.click();
//Check that my text is on the page
if (page.asText().contains("myText") {
System.out.println("Yes");
}
else System.out.println("No");
しかし、このアクションの後、ページに新しいメッセージはありません。私が知っているように、サーバーは隠しフィールド form_token と creation_time をチェックします。フィールドの正しい値を取得するには? または、問題を解決する他の方法を知っていますか?