1
HtmlUnitを使用してフォーム内にないオプションを選択しますか?それから私は結果として得られるページを取得する必要があります。ここに私が試したものがあります:フォーム内にないHtmlUnit選択オプション
public String getNewPage() throws Exception {
try (final WebClient webClient = new WebClient()) {
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setPopupBlockerEnabled(true);
webClient.getOptions().setJavaScriptEnabled(true);
final HtmlPage page = webClient.getPage(URL);
HtmlOption option1 = (HtmlOption) page.getElementById("1");
option1.removeAttribute("selected");
HtmlOption option5 = (HtmlOption) page.getElementById("5");
option5.setSelected(true);
// Some code missing here........
return newHtmlString;
}
オプションがクリックされると、ページが自動的に更新されます。正しいオプションを選択した後、新しいページを取得するにはどうすればよいですか?私が何をしたか
あなたはURLを提供できますか? –
ありがとうございますが、私は問題の解決策を見つけました。下に投稿します。 – Yster