ChromeOptions and DesiredCapabilities relations in Selenium and C# ChromeOptions and DesiredCapabilities relations in Selenium and C# selenium selenium

ChromeOptions and DesiredCapabilities relations in Selenium and C#


You don't need to set the browser name; ChromeOptions does that for you.

According to this comment

The .NET bindings are moving toward a pattern where DesiredCapabilites should not be used directly, even with RemoteWebDriver. To facilitate that, the ChromeOptions class has a ToCapabilities() method

And there's this comment

Much like --disable-javascript, the chromedriver will not work if you use --no-startup-window. It needs to launch a window to establish the connection with the AutomationProxy.

So that gets us to this:

var options = new ChromeOptions();options.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), options.ToCapabilities());

However, are you actually running a grid? If you're testing on a single machine it's even simpler:

IWebDriver driver = new ChromeDriver();