我在IE11上使用webdriver。每个selenium都有一组在IE11中运行所需的设置,其中之一是在互联网选项>高级>安全性中禁用“增强保护模式”(与互联网选项>安全性中启用的保护模式不同)。
问题是,我的组策略禁用了这些字段,这意味着我不能在没有请求组策略更改的情况下关闭它们。我想知道有没有IE功能或选项可以解决这个问题,比如Internet option > Security Enable Protection Mode设置中的caps‘IE’= True
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
发布于 2020-02-19 15:36:40
请尝试在C#应用程序中使用InternetExplorerOptions对象并将IntroduceInstabilityByIgnoringProtectedModeSettings属性设置为true,代码如下:
   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);
        }
    }如果您的应用程序是Java应用程序,请尝试使用以下代码:
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);来自this link的代码。
https://stackoverflow.com/questions/60289406
复制相似问题