Stop chromedriver console window from appearing, Selenium c#

Viewed 2521

I'm using Selenium and C#, headless chrome. I'm new to C#, so this might be something obvious, but I've looked at other questions and seen to add:

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

I added that to my Start() and the window still pops up, here is my start method:

            var chromeDriverService = ChromeDriverService.CreateDefaultService();
        chromeDriverService.HideCommandPromptWindow = true;
        var option = new ChromeOptions();
        option.AddArguments("--headless", "--no-sandbox", "--disable-web-security", "--disable-gpu", "--incognito", "--proxy-bypass-list=*", "--proxy-server='direct://'", "--log-level=3", "--hide-scrollbars");
        driver = new ChromeDriver(option);

Please let me know if you need anything else, thank you in advance!

1 Answers

You are very nearly at the solution you want. You set the property on the service, but never used it anywhere. What you want is the following:

var chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
var option = new ChromeOptions();
option.AddArguments("--headless", "--no-sandbox", "--disable-web-security", "--disable-gpu", "--incognito", "--proxy-bypass-list=*", "--proxy-server='direct://'", "--log-level=3", "--hide-scrollbars");
driver = new ChromeDriver(chromeDriverService, options);
Related