Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java PhantomJSDriver disable all logs in console

I'm developing a small console app using Selenium and I need to turn off all logs from it.

I have tried phantomJSDriver.setLogLevel(Level.OFF); but it does not work. I need help.

How do I disable all logs in console application that is using Selenium and Phantomjs (GhostDriver)?

like image 795
Alexey Kulikov Avatar asked Nov 24 '13 21:11

Alexey Kulikov


2 Answers

This one works for me.

DesiredCapabilities dcap = new DesiredCapabilities();
String[] phantomArgs = new  String[] {
    "--webdriver-loglevel=NONE"
};
dcap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
PhantomJSDriver phantomDriver = new PhantomJSDriver(dcap);
like image 78
Hery Avatar answered Nov 10 '22 20:11

Hery


Looking at the source files of org.openqa.selenium.phantomjs.PhanomJSDriverService while debugging, I discovered that it's actually ignoring documented log levels for ghostdriver itself. Doing this disables the bulk of ghostdriver output:

Logger.getLogger(PhantomJSDriverService.class.getName()).setLevel(Level.OFF);

Seems that GhostDriver should be be updated to not log when

phantomJSCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARG‌​S, "--webdriver-loglevel=NONE");  

is used.

like image 3
jsdevel Avatar answered Nov 10 '22 20:11

jsdevel