Cher
Cher

Reputation: 2937

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?

Upvotes: 3

Views: 2127

Answers (1)

st0ve
st0ve

Reputation: 574

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);

Upvotes: 3

Related Questions