If you are attempting to use:
- RemoteWebDriver class from Selenium Webdriver
- with a Chrome extension
- and .NET bindings
You will seriously struggle. Whether you are attempting to create your own Selenium Grid or use a service like Sauce Labs or Browser Stack, the answer on the web is nowhere to be found. I spent days looking for a solution to this problem and could not find it anywhere.
Finally, I turned to Stack Overflow where I posted a question and received an answer from Jim Evans. The problem with the .NET bindings is that unlike the Java implementation (and all of those examples online), we should NOT be using DesiredCapabilities, but rather should be using ChromeOptions. Below is the correct code to add a Chrome extension and get it working in a service like Sauce Labs.
Just a few key points that I’m going to mention because they are wrong all over the web for .NET:
- Use ChromeOptions instead of DesiredCapabilities
- You don’t need to specify CapabilityType.BrowserName as that is redundant
- When instantiating your RemoteWebDriver, just use the ToCapabilities() method on your ChromeOptions object.
Nikolay Advolodkin is a self-driven SDET on a lifelong mission to create profound change in the IT world and ultimately leave a legacy for his loved ones, community, and the world at large. Today, he serves as the CEO and Test Automation Instructor at UltimateQA.com and contributes informative articles to leading test automaton websites like SimpleProgrammer.com and TechBeacon.com