所有区域的“启用保护模式"必须设置为相同的值(启用或禁用) [英] Enable Protected Mode must be set to the same value (enabled or disabled) for all zones

查看:92
本文介绍了所有区域的“启用保护模式"必须设置为相同的值(启用或禁用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium Internet Explorer驱动程序,但是在尝试实例化该驱动程序时会中断:

I am trying to use the Selenium Internet Explorer driver but it is breaking when I try to instantiate it:

[TestInitialize]
public void TestInitialise() {
  ieDriver = new InternetExplorerDriver();
}

,出现以下错误:

启用保护模式必须设置为相同的值(启用或禁用 禁用)所有区域. (NoSuchDriver).

Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (NoSuchDriver).

我在此处,建议设置驱动程序的DesiredCapabilities,如下所示:

I have found an apparent solution to my problem here, which suggests setting the driver's DesiredCapabilities, as shown:

var capabilitiesInternet = new OpenQA.Selenium.Remote.DesiredCapabilities();
capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true);
IWebDriver webDriver = new InternetExplorerDriver(capabilitiesInternet);

唯一的问题是,我正在使用可以找到的最新版本的驱动程序,并且没有替代以DesiredCapabilities作为参数的InternetExplorerDriver.

The only problem is, I am using the latest version of the driver that I could find, and there is no override for InternetExplorerDriver that takes DesiredCapabilities as a parameter.

现在是否有一些新的或其他方式设置DesiredCapabilites,而不是我使用的示例?

Is there some new or other way of setting DesiredCapabilites now instead of the example that I used?

推荐答案

该设置可以解决该问题,但会带来一些细微的问题.您是否未正确设置IE的保护模式?这是正确的解决方案.

That setting will work around the problem but introduce some subtle problems. Have you not set up the Protected Modes of IE correctly? This is the correct solution to it.

此指南住在这里:

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

基本上只是在IE中为每个区域关闭保护模式.

Essentially just turn off protected mode in IE for each zone.

或者,如果您确实必须使用覆盖功能,则可以做两件事:

Alternatively if you really must use the override capability, then you either do two things:

使用InternetExplorerOptions类.请注意该属性的名称,它为您提供了一个大提示,使用它不是一个好主意.

Use the InternetExplorerOptions class. Note the name of the property, it gives you a big clue it is not a good idea to use it.

var options = new InternetExplorerOptions;
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
var driver = new InternetEplorerDriver(options);

或使用RemoteWebDriver,它可以接受ICapabilities接口的任何实现,该接口由DesiredCapabilites实现:

or use the RemoteWebDriver, which can take in any implementation of the ICapabilities interface, which DesiredCapabilites implements:

var capabilities = new DesiredCapabilities("internet explorer", string.Empty, new Platform(PlatformType.Windows));
capabilities.SetCapability("ignoreProtectedModeSettings", true);
var webDriver = new RemoteWebDriver(capabilities);

这篇关于所有区域的“启用保护模式"必须设置为相同的值(启用或禁用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆