How to disable warnings in HTMLUnitDriver?

2,719 views
Skip to first unread message

hella_funny

unread,
Jul 31, 2011, 11:56:13 PM7/31/11
to seleniu...@googlegroups.com
I get multiple warnings printed to stdout. How can I turn them off? Java WebDrier 2.2.0.
WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded javaScript element at 'http://.../util/json_source_autocomplete.js', but got 'application/x-javascript'. 
Thanks

Jaie Wilson

unread,
Aug 1, 2011, 12:30:40 AM8/1/11
to seleniu...@googlegroups.com
You server is responding with the application/x-javascript content-type for javascript files. If you can change it to use the content-type application/javascript the warning should go away.

Cheers,
Jaie

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/jecbygMV9pYJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Luke Inman-Semerau

unread,
Aug 1, 2011, 12:40:15 AM8/1/11
to seleniu...@googlegroups.com
HtmlUnit is logging those warnings. They are coming to standard out because your project doesn't define / configure a Logger.

Two options to get rid of those warnings if you can not change the content-type response from the server

1) (Easiest) Configure a logging mechanism to ignore warnings from com.gargoylesoftware.htmlunit  (log4j, slf4j, LOGBack)
2) To override the logging from going anywhere: Create a class that extends the HtmlUnitDriver to have a public method getWebClient that returns the HtmlUnit WebClient, call the setIncorrectnessListener method with another new class that is an implementation of IncorrectnessListener  which just has an empty notify() method.

hella_funny

unread,
Aug 1, 2011, 1:02:39 AM8/1/11
to seleniu...@googlegroups.com
Thanks,
I can't change content-type response, although I think it would be the best if I could specify content type in HTMLUnitDriver or HTMLUnitClient if it can handle it. If not, option one seems the easiest, but I really don't know how to go about getting log4j to to ignore warnings from com.gargoylesoftware.htmlunit. Could you point me to some code sample/tutorial that would explain this?
Thanks again

Jaie Wilson

unread,
Aug 1, 2011, 1:18:16 AM8/1/11
to seleniu...@googlegroups.com
Here is the html unit logging page: http://htmlunit.sourceforge.net/logging.html 

Here is a link to a sample log4j properties file that you can use in your test suite: http://htmlunit.svn.sf.net/viewvc/htmlunit/trunk/htmlunit/src/test/resources/log4j.properties?revision=5958&view=markup

Cheers,
Jaie

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/c3XqCrPbG6UJ.

Luke Inman-Semerau

unread,
Aug 1, 2011, 1:21:19 AM8/1/11
to seleniu...@googlegroups.com
Just to be clear, this is just a warning and HtmlUnit is actually still parsing / executing the javascript.

Since you mention log4j I'll assume you have that jar included with your project (otherwise add it).

Create a log4j.properties file and place it in your resources directory. Add this line to it:

log4j.logger.com.gargoylesoftware.htmlunit=ERROR

Which means only Error or Fatal level loggings will be "logged" ~ default stdout. Don't remember if there's much more to do.


I used to use log4j... now using LOGBack: http://logback.qos.ch/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/c3XqCrPbG6UJ.
Reply all
Reply to author
Forward
0 new messages