Reputation: 330
I have software which does automated testing via chrome browser, but now this program failed with error message "Vector smash protection is enabled." I've found a solution for this case, but this solution implemented via java API.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--incognito"));
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
WebDriver driver = new ChromeDriver(capabilities);
How to implement a code the same as above via c#?
Upvotes: 3
Views: 1582
Reputation: 1577
You need a Dictionary
// Capabilities Values
var imageSetting = new Dictionary<string, object> {{"images", 2}};
var content = new Dictionary<string, object> {{"profile.default_content_settings", imageSetting}};
var prefs = new Dictionary<string, object> {{"prefs", content}};
// List of Chromium Command Line Switches
var options = new ChromeOptions();
options.AddArguments(
"--disable-extensions",
"--disable-features",
"--disable-popup-blocking",
"--disable-settings-window");
// Add the Capabilities
var field = options.GetType().GetField("additionalCapabilities", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
var dict = field.GetValue(options) as IDictionary<string, object>;
if (dict != null) dict.Add(ChromeOptions.Capability, prefs);
}
// Create the Chrome Driver
var chromeDriver = new ChromeDriver(options);
Also you can send the driver path when you create the ChromeDriver object.
Upvotes: 2