MarkusBernhardt / robotframework-selenium2library-java

Java port of the Selenium 2 (WebDriver) Python library for Robot Framework
Apache License 2.0
46 stars 51 forks source link

How to turn off htmlunit logging? #85

Closed php-coder closed 4 years ago

php-coder commented 7 years ago

I didn't found how to turn off htmlunit logging. At this moment it produces a lot of noise:

ERROR] runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: :x).] sourceName=[http://127.0.0.1:8080/public/jquery/1.9.1/jquery.min.js] line=[4] lineSource=[null] lineOffset=[0]
[WARNING] CSS error: 'http://127.0.0.1:8080/public/bootstrap/3.3.7/css/bootstrap.min.css' [5:56298] Error in expression; ':' found after identifier "progid".
[WARNING] CSS error: 'http://127.0.0.1:8080/public/bootstrap/3.3.7/css/bootstrap.min.css' [5:113847] Error in expression; ':' found after identifier "progid".
[WARNING] CSS error: 'http://127.0.0.1:8080/public/bootstrap/3.3.7/css/bootstrap.min.css' [5:114390] Error in expression; ':' found after identifier "progid".
[WARNING] CSS error: 'http://127.0.0.1:8080/public/bootstrap/3.3.7/css/bootstrap.min.css' [5:115558] Invalid color "#000\9".
[ERROR] runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: :x).] sourceName=[http://127.0.0.1:8080/public/jquery/1.9.1/jquery.min.js] line=[4] lineSource=[null] lineOffset=[0]

I have src/test/resources/logback-test.xml file where these messages are turned off but htmlunit doesn't use this file.

How to manage logging for htmlunit in this case?

php-coder commented 4 years ago

An update in case it can be helpful to someone else:

The loglevel is set and managed by Maven. Here is the details: https://maven.apache.org/maven-logging.html It uses slf4j and SimpleLogger by default. In order to suppress annoying htmlunit messages, I passed the following options:

-Dorg.slf4j.simpleLogger.log.com.gargoylesoftware.htmlunit.DefaultCssErrorHandler=error
-Dorg.slf4j.simpleLogger.log.com.gargoylesoftware.htmlunit.html.InputElementFactory=warn
-Dorg.slf4j.simpleLogger.log.com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl=error

In order to use them always and by default, I put these lines into .m2/jvm.config file within a project.