我正在使用HTMLunit在网站上填写表单,但在需要提交它的HTMLanchor上卡住了。
html代码:
<a id="syi-place-ad-button" class="button primary medium "><span>Plaats uw advertentie</span></a>
尝试单击它:
HtmlAnchor submitButton = (HtmlAnchor) page2.getElementById("syi-place-ad-button");
form2.appendChild(submitButton);
page3 = submitButton.click();;
webClient.waitForBackgroundJavaScript(10*1000);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
WebResponse response = page3.getWebResponse();
String content = response.getContentAsString();
System.out.println(content);
webClient.closeAllWindows();最后给出了这个错误:
== CALLING JAVASCRIPT ==
function (e) {
return st === t || e && st.event.triggered === e.type ? t : st.event.dispatch.apply(s.elem, arguments);
}
======= EXCEPTION END ========有人能帮我找出我在这里可能遗漏了什么或做错了什么吗?
发布于 2014-01-08 13:43:03
尽管setJavaScriptEnabled(boolean)在2.13中被弃用,但它被添加到WebClient的WebClientOptions成员中。这是医生。
要禁用JavaScript,应执行以下操作:
webClient.getOptions().setJavaScriptEnabled(false);
https://stackoverflow.com/questions/20920727
复制相似问题