Vivian Yung
Vivian Yung

Reputation: 89

Webdriver disable enhanced protected mode

I am using webdriver on IE11. And per selenium there are a set of required setting to run in IE11 one of them is to disabled "enhanced protected mode" in Internet Option > Advanced > Security (not the same as the enabled protected mode in Internet Option > Security)

The problem is, my group policy's has those field disabled, meaning I cannot turn them off without requesting for a group policy change. I was wondering if there is a IE capability or option out there that can work around this issue like the caps['ignoreProtectedModeSettings'] = True for the Internet Option > Security Enable Protection Mode setting

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

Upvotes: 0

Views: 1314

Answers (1)

Zhi Lv
Zhi Lv

Reputation: 21383

Please try to use the InternetExplorerOptions object and set the IntroduceInstabilityByIgnoringProtectedModeSettings property to true in C# application, code as below:

   private const string URL = @"https://www.bing.com/";
    private const string IE_DRIVER_PATH = @"E:\webdriver\IEDriverServer_x64_3.14.0";  // where the Selenium IE webdriver EXE is.
    static void Main(string[] args)
    {
        InternetExplorerOptions opts = new InternetExplorerOptions() { 
            IntroduceInstabilityByIgnoringProtectedModeSettings = true,
            IgnoreZoomLevel = true,
        };
        using (var driver = new InternetExplorerDriver(IE_DRIVER_PATH, opts))
        {
            driver.Navigate().GoToUrl("https://www.bing.com/");  

            //someTextbox.SendKeys("abc123");
            var element = driver.FindElementById("sb_form_q");
            var script = "document.getElementById('sb_form_q').value = 'webdriver';";

            IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
            jse.ExecuteScript(script, element);

            //element.SendKeys("webdriver");
            element.SendKeys(Keys.Enter);
        }
    }

If you application is a Java application, try to use the following code:

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

Code from this link.

Upvotes: 0

Related Questions