Webdriver disable enhanced protected mode

前端 未结 1 407
陌清茗
陌清茗 2021-01-29 05:35

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 > Adv

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-29 06:08

    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.

    0 讨论(0)
提交回复
热议问题