How to Ignore Protected Mode Settings for Internet Explorer Using Setcapability() Through Selenium and Java

How to ignore protected Mode Settings for Internet Explorer using setCapability() through Selenium and Java?

It seems you were almost there. You need to use the method merge() from MutableCapabilities Class to merge the DesiredCapabilities type of object into InternetExplorerOptions type object and initiate the WebDriver and WebClient instance by passing the InternetExplorerOptions object as follows :

DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
cap.setCapability("nativeEvents", false);
cap.setCapability("unexpectedAlertBehaviour", "accept");
cap.setCapability("ignoreProtectedModeSettings", true);
cap.setCapability("disable-popup-blocking", true);
cap.setCapability("enablePersistentHover", true);
cap.setCapability("ignoreZoomSetting", true);
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
InternetExplorerOptions options = new InternetExplorerOptions();
options.merge(cap);
WebDriver driver = new InternetExplorerDriver(options);

Enable Protected Mode must be set to the same value (enabled or disabled) for all zones

That setting will work around the problem but introduce some subtle problems. Have you not set up the Protected Modes of IE correctly? This is the correct solution to it.

Guide of this lives here:

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

Essentially just turn off protected mode in IE for each zone.

Alternatively if you really must use the override capability, then you either do two things:

Use the InternetExplorerOptions class. Note the name of the property, it gives you a big clue it is not a good idea to use it.

var options = new InternetExplorerOptions;
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
var driver = new InternetEplorerDriver(options);

or use the RemoteWebDriver, which can take in any implementation of the ICapabilities interface, which DesiredCapabilites implements:

var capabilities = new DesiredCapabilities("internet explorer", string.Empty, new Platform(PlatformType.Windows));
capabilities.SetCapability("ignoreProtectedModeSettings", true);
var webDriver = new RemoteWebDriver(capabilities);


Related Topics



Leave a reply



Submit