Cher Cher - 3 years ago 152
C# Question

How to use IE options with IWebDriver?

I have the following code which does exactly what I want:

private IWebDriver driver;
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
driver = new InternetExplorerDriver(options);


However, people I work with need the driver variable to be a
IWebDriver
instead:

DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();
capabilities.SetCapability("ie.ensureCleanSession", true);
driver = new RemoteWebDriver(new Uri(remoteAddress), capabilities, TimeSpan.FromSeconds(10));


So I was wondering if there is a way to set the following property:

options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;


using a
RemoveWebDriver
? Can I set it in
DesiredCapabilities
object?

Something like this maybe (can't find something like this):

capabilities.SetCapability("ie.IntroduceInstabilityByIgnoringProtectedModeSettings ", true);


Or to include the
options
object in
RemoveWebDriver
?

Answer Source

If you need to use both Options and Capabilities, you can add options into your capabilities and then pass the capabilities into the remote webdriver as a parameter.

capabilities.SetCapability(InternetExplorerOptions.Capability, options);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download