Java PhantomJSDriver disable all logs in console
Asked Answered
S

3

14

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)?

Southern answered 24/11, 2013 at 21:36 Comment(0)
G
-2
PhantomJSDriverService service = new PhantomJSDriverService.Builder()
        .usingPhantomJSExecutable(new File(VariableClass.phantomjs_file_path))
        .withLogFile(null)
        .build();
Gnat answered 7/3, 2014 at 13:48 Comment(0)
G
22

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);
Greenlet answered 9/5, 2014 at 10:19 Comment(5)
I'm using the same config file but it doesn't work, the ghost driver still print all the INFO log on the screen. This is my config lines: phantomJSCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, "--webdriver-loglevel=NONE"); phantomJSCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "/usr/lib/phantomjs/bin/phantomjs");Armor
I found this in the source code: * NOTE: This is useful only when used together with PhantomJSDriverService#PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY. * So it is not supposed to be used like this. But is there way to set the PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY?Armor
Somehow it works for me without setting that property. However I see the way to set it here. Maybe you can try it out.Greenlet
@Greenlet - How do I do this in Ruby ?Downstate
This one works for me with Phantoms js 1.2 and Selenium 2.53 version.Humidor
L
3

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.

Lethargic answered 11/5, 2015 at 9:14 Comment(0)
G
-2
PhantomJSDriverService service = new PhantomJSDriverService.Builder()
        .usingPhantomJSExecutable(new File(VariableClass.phantomjs_file_path))
        .withLogFile(null)
        .build();
Gnat answered 7/3, 2014 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.