首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Webdriver禁用增强保护模式

Webdriver禁用增强保护模式
EN

Stack Overflow用户
提问于 2020-02-19 05:01:08
回答 1查看 479关注 0票数 0

我在IE11上使用webdriver。每个selenium都有一组在IE11中运行所需的设置,其中之一是在互联网选项>高级>安全性中禁用“增强保护模式”(与互联网选项>安全性中启用的保护模式不同)。

问题是,我的组策略禁用了这些字段,这意味着我不能在没有请求组策略更改的情况下关闭它们。我想知道有没有IE功能或选项可以解决这个问题,比如Internet option > Security Enable Protection Mode设置中的caps‘IE’= True

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

EN

回答 1

Stack Overflow用户

发布于 2020-02-19 15:36:40

请尝试在C#应用程序中使用InternetExplorerOptions对象并将IntroduceInstabilityByIgnoringProtectedModeSettings属性设置为true,代码如下:

代码语言:javascript
运行
复制
   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应用程序,请尝试使用以下代码:

代码语言:javascript
运行
复制
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的代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60289406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档