【问题标题】:Internet Explorer protected mode errorInternet Explorer 保护模式错误
【发布时间】:2014-10-09 22:14:14
【问题描述】:

我在 Visual Studio 中的代码使用的是 selenium webdriver 2.24.0。我正在使用的测试框架是 Nunit。在 2.24.0 版本发布之前,我的代码运行良好(加载不同的浏览器、驱动网站)。

我将新的 IE 独立服务器添加到我的项目中。

现在每当我运行我的代码时,NUnit 都会遇到此错误消息。

 FirstSeleniumTest.SeleniumTest.TestGoogle:
SetUp : System.InvalidOperationException : Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (NoSuchDriver)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

然后弹出命令提示符。

Started InternetExplorerDriver server (64-bit)
2.24.0.0
Listening on port 50329

我在我的 IE 上禁用了保护模式。还是没有运气。

我怎样才能让我的代码恢复到正确的网络驱动?

【问题讨论】:

  • 您确定为所有 4 个安全区域(Int​​ernet、本地 Intranet、受信任的站点、受限制的站点)禁用保护模式吗?
  • 受限制站点上仍启用保护模式。感谢您的修复。回答这个问题,我会接受
  • 相关:底层 Selenium 功能请求code.google.com/p/selenium/issues/detail?id=1795
  • @RubenBartelink 并不是一个真正的功能请求,更像是该功能完全按照它应该的方式工作。请参阅http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html 了解更多详情。
  • @JimEvans 感谢您指出这一点 - 非常详细的文章(以及出色的 TL;DR 总结)。不能说我花时间正确阅读了我引用的文章(我同步了设置并得到了一个生命) - 我很快得出结论,这个问题是在问我当时想要什么 - 所有驱动程序在所有情况下都可以使用 OOTB,而无需了解任何内容,是的,即使在图片中使用 ESC 也是如此:D

标签: .net selenium nunit webdriver


【解决方案1】:

您应该确保为所有 4 个安全区域(Int​​ernet、本地 Intranet、受信任的站点、受限制的站点)启用或禁用保护模式。 换句话说,所有安全区域的设置值应该相同。

【讨论】:

  • 投反对票,因为答案意味着必须为所有区域禁用保护模式。这是不正确的。可以启用或禁用保护模式,只要所有区域的值都相同。更正暗示保护模式必须被禁用的答案,我将删除反对票。
  • @JimEvans 嘿,吉姆,我不知道为什么,但它只在关闭时才对我有用。有任何想法吗?我使用的是带有 IE 10 的 Windows 7(64 位)。
【解决方案2】:

只是为了添加到已经正确的答案,如果将所有值设置为相同不是一个选项,(需要禁用安全性是某些区域,但希望在其他区域保持启用安全性)您还可以使用重载初始化驱动程序包括InternetExplorerOptions,并使用

new InternetExplorerOptions() { IntroduceInstabilityByIgnoringProtectedModeSettings = true}

【讨论】:

    【解决方案3】:

    您需要将每个区域的保护模式设置设置为相同的值。 阅读:http://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration

    【讨论】:

      【解决方案4】:

      我同意 Alexander 的说法,但如果您的公司不允许您对 IE 设置进行任何更改怎么办。


      以下内容对我有用:

          File file = new File("M:\\dev\\ria\\iedriver\\2.42.0\\install\\exec\\IEDriverServer.exe");
          System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
      
          DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
          caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);  
          caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
      
          WebDriver driver = new InternetExplorerDriver(caps);
          driver.get("http://www.google.com");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多