Hide command prompt window in Selenium WebDriver .NET binding

Published: by Creative Commons Licence

As of Selenium 2.40.01, Selenium WebDriver's .NET binding supports hiding the command prompt window created by ChromeDriver, IEDriver or PhantomJSDriver. The following code snippets demonstrate how to achieve it in C#.

However, according to the developer2, it is highly discouraged to use this option, because this will make it hard to debug zombie driver processes when WebDriver code exits unexpectedly. Also note that currently PhantomJSDriver has a constructor which takes in PhantomJSDriverService parameter alone, while ChromeDriver and InternetExplorerDriver don't have this constructor overload. A pull request has been made here, which will add this missing constructor overload to these two classes.

Environment Tested:
Windows 7, Selenium 2.40.0
Chrome 33 + ChromeDriver 2.9, IE 10 + IEDriver 2.40.0, PhantomJSDriver 1.9.7

ChromeDriver

var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new ChromeDriver(driverService, new ChromeOptions());

InternetExplorerDriver

var driverService = InternetExplorerDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new InternetExplorerDriver(driverService, new InternetExplorerOptions());

PhantomJSDriver

var driverService = PhantomJSDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new PhantomJSDriver(driverService);
  1. CHANGELOG for Selenium 2.40.0. 

  2. Comment to "Hide the IEDriver command window" by Jim Evans.