Java PhantomJSDriver disable all logs in console
11,814
Solution 1
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);
Solution 2
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_ARGS, "--webdriver-loglevel=NONE");
is used.
Related videos on Youtube
Author by
Alexey Kulikov
Updated on June 04, 2022Comments
-
Alexey Kulikov almost 2 years
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)?
-
tribbloid almost 10 yearsI'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");
-
tribbloid almost 10 yearsI 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?
-
Hery almost 10 yearsSomehow it works for me without setting that property. However I see the way to set it here. Maybe you can try it out.
-
javanoob over 9 yearsExcellent..this worked for me atleast and thanks alot
-
stack1 over 9 years@Hery - How do I do this in Ruby ?
-
Bằng Rikimaru over 6 yearsThis one works for me with Phantoms js 1.2 and Selenium 2.53 version.