24

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#.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
user3240928
  • 525
  • 2
  • 4
  • 16
  • See answer here https://sqa.stackexchange.com/questions/7898/selenium-c-4-0-release-says-you-can-hide-the-command-prompt-how-do-you-actual – Matthew Lock Aug 07 '17 at 23:12

3 Answers3

46

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.

mscrivo
  • 1,107
  • 12
  • 14
  • as of chrome 79, there is no such method as "HideCommandPromptWindow" in ChromeDriverService object. – Nadee Jan 31 '20 at 05:30
25

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");
Florent B.
  • 41,537
  • 7
  • 86
  • 101
  • 1
    That does not work because HideCommandPromptWindow does not exist – user3240928 Mar 05 '16 at 21:43
  • 5
    The HideCommandPromptWindow property is part of the official Selenium C# client library 2.52.0.0: http://selenium-release.storage.googleapis.com/2.52/selenium-dotnet-2.52.0.zip – Florent B. Mar 06 '16 at 19:56
0

Hello chrome driver command hide coding

public IWebDriver drv;
public AnaSayfa()
{
    CheckForIllegalCrossThreadCalls = false;
    ChromeDriverService service = ChromeDriverService.CreateDefaultService();
    service.HideCommandPromptWindow = true;
    drv = new ChromeDriver(service);
    InitializeComponent();
}
void BekraHayrNesterGo()
{
    drv.Navigate().GoToUrl("https://www.example.com/");
}

This shape can hide cmd

Wang Liang
  • 4,244
  • 6
  • 22
  • 45
  • 8
    Please do not enter links to your own website, especially without attribution that it is indeed your website. Since it seems irrelevant to the answer, I have changed to the default `example.com`. Please read [How to not be a spammer](https://stackoverflow.com/help/promotion), and refrain from linking to non-English websites in the future, as Stack Overflow is strictly English-only. – Adriaan Jan 17 '19 at 12:25