[英]How to enable javascript in HtmlUnit
这是我对HtmlUnit的编码
final WebClient webClient = new WebClient();
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setTimeout(20000);
//webClient.setSSLClientCertificate(certificateUrl,
certificatePassword, certificateType);
HtmlPage page1 = (HtmlPage)webClient.getPage("http://oneurl");
但我有错误
WARN APOPERATOR "htmlunit.IncorrectnessListenerImpl" Obsolete content type encountered: 'text/javascript'.
ERROR APOPERATOR "javascript.StrictErrorReporter" runtimeError: message=[The data necessary to complete this operation is not yet available.] sourceName=[http://easypay.swisscom.ch/charging-engine-checkout/js/libs/jquery-1.9.1.min.js] line=[3] lineSource=[null] lineOffset=[0]
WARN APOPERATOR "html.HTMLDocument" getElementById(sizzle-1447848465222) did a getElementByName for Internet Explorer
WARN APOPERATOR "htmlunit.IncorrectnessListenerImpl" Obsolete content type encountered: 'text/javascript'.
谁能帮忙在HtmlUnit中启用javascript吗?
这已经启用了JavaScript:
webClient.getOptions().setJavaScriptEnabled(true);
在日志中看到的是警告消息,不应使用内容类型,但可以放心地忽略这些消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.