How to execute Selenium Chrome WebDriver in silent mode?

When using Chrome Selenium WebDriver, it will output diagnostic output when the servers are started:

Started ChromeDriver (v2.0) on port 9515

I do not want to see these messages, how can I suppress them?

I do this

ChromeOptions options = new ChromeOptions();
options.AddArgument("--silent");
IWebDriver Driver = new ChromeDriver(options);

But diagnostic output is not suppress.


Solution 1:

I simply do this

ChromeOptions options = new ChromeOptions();
options.AddArgument("--log-level=3");
IWebDriver driver = new ChromeDriver(options);

Solution 2:

Good question, however, I don't know where you got that .AddArgument("--silent"); thing, as that's Chrome's command line switch, not for ChromeDriver. Also, there isn't a Chrome switch called --silent anyway.

Under OpenQA.Selenium.Chrome namespace, there is class called ChromeDriverService which has a property SuppressInitialDiagnosticInformation defaults to false. Basically what you might want to do is to create ChromeDriverService and pass it into ChromeDriver's constructor. Please refer to the documentation here.

Here is the C# code that suppresses ChromeDriver's diagnostics outputs.

ChromeOptions options = new ChromeOptions();

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;

IWebDriver driver = new ChromeDriver(service, options);

EDIT: ChromeDriver (not Chrome) has a command line argument --silent, which is supposed to work. SuppressInitialDiagnosticInformation in .NET binding does exactly that. However, it seems only suppress some of the messages.

Here is a closed chromedriver ticket: Issue 116: How to disable the diagnostic messages and log file from Chrome Driver?

Solution 3:

For me no one of previous answers did not help , my solution was:

ChromeDriverService service = ChromeDriverService.CreateDefaultService(driverLocation);
service.SuppressInitialDiagnosticInformation = true;
service.HideCommandPromptWindow = true;
var driver = new ChromeDriver(service, options);

Solution 4:

For me the only thing that worked for

   selenium-chrome-driver-2.48.2.jar
   chromedriver 2.20
   selenium-java-2.48.2.jar

was

   ChromeOptions options = new ChromeOptions();
   System.setProperty("webdriver.chrome.args", "--disable-logging");
   System.setProperty("webdriver.chrome.silentOutput", "true");
   driver = new ChromeDriver(options);