How to execute Selenium Chrome WebDriver in silent mode?
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);
Solution 5
try this code it will hide browser with "headless" Argument but Chrome ver should > 58
( and even you can hide command prompt window )
IWebDriver driver;
ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-extensions");
options.AddArgument("test-type");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("no-sandbox");
options.AddArgument("--headless");//hide browser
ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"chromedriverExepath\");
service.SuppressInitialDiagnosticInformation = true;
//service.HideCommandPromptWindow = true;//even we can hide command prompt window (with un comment this line)
options.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
driver = new ChromeDriver(service, options);
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://www.example.com");
![LeMoussel](https://i.stack.imgur.com/GvorM.png?s=256&g=1)
LeMoussel
Problem solver. Je recherche, je développe, je teste, je veille, ..., Passionné par toutes les techniques de Dév. (.NET, C#, PHP, JavaScript, ...).
Updated on May 30, 2020Comments
-
LeMoussel about 4 years
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.