java - How to enable javascript in HtmlUnit - Stack Overflow

This is my coding for HtmlUnitfinal WebClient webClient = new WebClient();webClient.getOptions().setJa

This is my coding for 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");

But i got error like

WARN APOPERATOR "htmlunit.IncorrectnessListenerImpl" Obsolete content type encountered: 'text/javascript'.
ERROR APOPERATOR "javascript.StrictErrorReporter" runtimeError: message=[The data necessary to plete this operation is not yet available.] sourceName=[.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'.

Can anyone please help to enable javascript in HtmlUnit?

This is my coding for 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");

But i got error like

WARN APOPERATOR "htmlunit.IncorrectnessListenerImpl" Obsolete content type encountered: 'text/javascript'.
ERROR APOPERATOR "javascript.StrictErrorReporter" runtimeError: message=[The data necessary to plete this operation is not yet available.] sourceName=[http://easypay.swiss.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'.

Can anyone please help to enable javascript in HtmlUnit?

Share Improve this question edited Nov 18, 2015 at 14:08 Ahmed Ashour 5,61110 gold badges39 silver badges62 bronze badges asked Nov 18, 2015 at 13:04 Suresh SSuresh S 812 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

This already enables the JavaScript:

webClient.getOptions().setJavaScriptEnabled(true);

What you see in the logs are warning messages that the content type should not be used, but you can safely ignore them.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744790874a4593907.html

相关推荐

  • java - How to enable javascript in HtmlUnit - Stack Overflow

    This is my coding for HtmlUnitfinal WebClient webClient = new WebClient();webClient.getOptions().setJa

    9小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信