I'm trying to instantiate an InternetExplorerDriver in C#, and every time I do I get the following error message:
System.InvalidOperationException : Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (NoSuchDriver)
Now I'm not sure how to sort this out, but the line of code that triggers the error in question is:
IWebDriver driver = new InternetExplorerDriver();
The documentation for InternetExplorerDriver suggests that I can pass in an ICapabilities
object in an overloaded constructor, but that only has the properties BrowserName
, IsJavaScriptEnabled
, Platform
and Version
. None of these seem to suggest that they can solve the issue.
Is there something I need to do within the implementation to sort this out? Or do I have to modify some settings within IE9 itself?
For reference, if your wish to override the security options here's the c# code:
using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.IE; namespace SeleniumTests { [TestFixture] public class Test { private IWebDriver driver; [SetUp] public void Setup() { var options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; driver = new InternetExplorerDriver(options); } } }
Update:
My previous answer used an older version of Selenium 2.0, I've now updated the code to work against Selenium DotNet-2.21.0 and included the correct namespaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With