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
Creating an instance of ChromeOptions class: See below code: ChromeOptions options = new ChromeOptions(); options. addArguments("disable-infobars"); ChromeDriver driver = new ChromeDriver(options);
For Windows, Allow Read & Execute Permissions on chromedriver.exe for Everyone: Right Click chromedriver.exe > Properties On ChromeDriver.
For the ChromeOptions, we have to create an object for that class. Then we shall take the help of the add_argument method and pass the option we want to send to the browser as a parameter to the method. Finally, this information must be given to the web driver.
When I was setting chrome up with
selenium-chrome-driver-2.48.2.jar chromedriver 2.20 selenium-java-2.48.2.jar
none of the above answers worked for me, Since I see some of the answers are a few years old, I will post what worked for me.
ChromeOptions chromeOptions = setupChromeOptions(); System.setProperty("webdriver.chrome.logfile", "\\path\\chromedriver.log"); System.setProperty("webdriver.chrome.driver", "\\path\\chromedriver.exe"); System.setProperty("webdriver.chrome.args", "--disable-logging"); System.setProperty("webdriver.chrome.silentOutput", "true"); driver = new ChromeDriver(chromeOptions);
Hinted by this Chromedriver ticket (about the silent
option), I looked in the source of ChromeDriverService.java
, and found a reference to "webdriver.chrome.logfile"
.
After adding -Dwebdriver.chrome.logfile="/dev/null"
to my java
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):
DIR=path/to/dir/containing/selenium/and/stuff
cd "$DIR" && java -cp "$DIR\
:$DIR/output\
:$DIR/bin/selenium-server-standalone-2.33.0.jar" \
-Dwebdriver.chrome.driver="$DIR/bin/chromedriver" \
-Dwebdriver.chrome.args="--disable-logging" \
-Dwebdriver.chrome.logfile="/dev/null" \
AllTests
If you're on Windows:
set DIR=path\to\dir\containing\selenium\and\stuff
cd "%DIR%" && java -cp "%DIR%;%DIR%\output;%DIR%\bin\selenium-server-standalone-2.33.0.jar" ^
-Dwebdriver.chrome.driver="%DIR%\bin\chromedriver.exe" ^
-Dwebdriver.chrome.args="--disable-logging" ^
-Dwebdriver.chrome.logfile=NUL ^
AllTests
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 containing public 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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With