4

I'm updating to version 2.40 and was looking at the change log. http://selenium.googlecode.com/git/dotnet/CHANGELOG

It says "Now provide an option to hide command prompt window for driver service executables (IEDriverServer.exe, chromedriver.exe, etc.) in .NET bindings."

I can't find what setting to use to make this happen. How do I do it?

1
  • How do I overload my edge driver() with DriverDirectory, DriverService and Options. Or how do I apply all three to my driver? So I'm doing this: ``` EdgeOptions options = new EdgeOptions(); options.AddArgument("headless"); EdgeDriverService myDriverService = new EdgeDriverService.CreateDefaultService(); myDriverService.HideCommandPromptWindow = true; EdgeDriver edgeDriver = new EdgeDriver(Setup.DirectoryPath, options); //Want to apply myDriverService //in here how would I apply a myDriverService to the method, there's no overload for Driver Directory, options and Driver Service, only Driver Di
    – dutoit077
    Commented Apr 21, 2021 at 23:11

2 Answers 2

11

Yes, you can hide command prompt window now in Selenium 2.40.0. I was writing a blog article about this earlier, which you might want to have a look here.

Please note that hiding command prompt window is not recommended.

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);
4
  • Interesting that it is an option, even though it is not suggested. Do you know an acceptable use case for this?
    – AlignedDev
    Commented Mar 5, 2014 at 20:01
  • 1
    @Aligned: If someone is using Selenium to develop an application that runs on client's computer. So it is a good idea to hide command window. Otherwise for testing purposes, I can't think of any.
    – Yi Zeng
    Commented Mar 5, 2014 at 20:30
  • 2
    @Aligned It's an option because enough people who use the .NET bindings asked for it, even though the maintainer of the .NET bindings believes it to be a mistake to hide the window. If, for some reason, your WebDriver code fails, and incorrectly doesn't call the .Quit method, with the command prompt window showing, it's blatantly obvious there's an extra process running. With the command prompt window hidden, it's not obvious.
    – JimEvans
    Commented Mar 26, 2014 at 22:25
  • @YiZeng Is there any way to achieve this in Python ? Commented Mar 19, 2017 at 18:06
1
ChromeDriverService chromeservice = ChromeDriverService.CreateDefaultService();
   chromeservice.HideCommandPromptWindow = true; //hide console window
   ChromeDriver driver = new ChromeDriver(chromeservice);

   FirefoxDriverService firefoxservice = FirefoxDriverService.CreateDefaultService();
   firefoxservice.HideCommandPromptWindow = true; //hide console window
   FirefoxDriver driver = new FirefoxDriver(firefoxservice);

Several other Selenium tools

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.