When I launch Selenium's WebDriver (Chromedriver). A console window (chromedriver.exe) runs and it opens Chrome. I need to know how I can hide those like a silent mode because I get messy when there are too many open. I am using C#.
Selenium Webdriver can run in the background, i.e. without opening a browser window, by running it in Headless mode.
We can hide the Firefox window in Selenium webdriver. This can be done by making the browser headless. We shall achieve this with the FirefoxOptions class. We shall then create an object option of that class.
Post version 59, Chrome supports headless execution. ChromeOptions class is utilized to modify the default characteristics of the browser. The addArguments method of the ChromeOptions class is used for headless execution and headless is passed as a parameter to that method.
As of Chrome 59, you can now also hide the chrome browser window by using headless mode:
options.AddArgument("headless");
and in combination with:
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
it runs in complete silence.
To my knowledge it's not possible to hide the browser. However, you can hide the console and set the browser offscreen:
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
var options = new ChromeOptions();
options.AddArgument("--window-position=-32000,-32000");
var driver = new ChromeDriver(service, options);
driver.Navigate().GoToUrl("https://www.google.co.uk");
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