How to set up Selenium and ChromeDriver to run in headless mode How to set up Selenium and ChromeDriver to run in headless mode selenium selenium

How to set up Selenium and ChromeDriver to run in headless mode


Taking out the debugger address made it work.

var chromeOptions = new ChromeOptions{    BinaryLocation = @"C:\Users\<USERNAME>\AppData\Local\Google\Chrome SxS\Application\chrome.exe",};


In case that others will get here while googling...

What worked for me was to download the latest chrome-driver from this link:https://sites.google.com/a/chromium.org/chromedriver/downloads

Happy coding :)


            case "chrome9515headless":                ChromeOptions chromeOptions = new ChromeOptions();                chromeOptions.AddArgument("--headless");                chromeOptions.AddArgument("--disable-gpu");                chromeOptions.AddArgument("--disable-infobars");                chromeOptions.AddArgument("--disable-extensions");                chromeOptions.AddArgument("--window-size=1200,900");                chromeOptions.AddArgument("--disable-browser-side-navigation");                webDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:9515"),                    chromeOptions.ToCapabilities());                break;            case "chrome9515canary":                ChromeOptions chromeOptionsCanary = new ChromeOptions();                chromeOptionsCanary.BinaryLocation= @"C:\Users\********\AppData\Local\Google\Chrome SxS\Application\chrome.exe";                //chromeOptionsCanary.AddArgument("--headless");                //chromeOptions.AddArgument("--disable-gpu");                chromeOptionsCanary.AddArgument("--disable-infobars");                chromeOptionsCanary.AddArgument("--disable-extensions");                chromeOptionsCanary.AddArgument("--window-size=1200,900");                chromeOptionsCanary.AddArgument("--disable-browser-side-navigation");                webDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:9515"),                    chromeOptionsCanary.ToCapabilities());                break;