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

Leave a Comment