I am trying to disable the output to the console for chrome. If I pass the --start-maximized option it works fine. I may have the wrong command?
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--silent"));
chrome = new ChromeDriver(_chromeservice,capabilities);
I also tried
ChromeOptions options = new ChromeOptions();
options.addArguments("silent");
chrome = new ChromeDriver(options);
Output
Started ChromeDriver port=26703 version=23.0.1240.0 log=/Brett/workspace/TestNG/chromedriver.log [1214/161331:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends [1214/161331:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends [1214/161331:ERROR:ipc_sync_channel.cc(378)] Canceling pending sendsBlockquote
As of Selenium 3 at least, you can use ChromeDriverService and its inner class Builder to be able to launch the driver in silent mode.
A oneliner for that:
The constructor is straight-forward, you create a new service builder setting silent to true (that's the critical part) and you finally build it into a ChromeDriverService which is required by ChromeDriver's constructor.
When I was setting chrome up with
Try "
--disable-logging
" instead.Hinted by this Chromedriver ticket (about the
silent
option), I looked in the source ofChromeDriverService.java
, and found a reference to"webdriver.chrome.logfile"
.After adding
-Dwebdriver.chrome.logfile="/dev/null"
to myjava
command, the logs became readable again: The usless ChromeDriver logs were gone, while theSystem.out.println
calls and exceptions are still shown in the console.I start
java
with the following parameters (Linux / Mac):If you're on Windows:
Explanation for the composition of my classpath (
-cp
): My tests are located in a directory at "$DIR/output". The Selenium jar file is placed in "$DIR/bin/selenium-server-standalone-2.33.0.jar". "AllTests" is the name of my class containingpublic static void main(String[] args)
- this launches my tests.The other parameters are self-explanatory, adjust it to your needs. For convenience (used in a shell/batch script), I've declared the common directory in a variable
DIR
.