我正在尝试使用Selenium Internet Explorer驱动程序,但是当我尝试实例化它时它正在破坏:
[Testinitialize]
public void Testinitialise() {
ieDriver = new InternetExplorerDriver();
}
出现以下错误:
Enable Protected Mode must be set to the same value (enabled or
disabled) for all zones. (NoSuchDriver).
我找到了一个明显的解决方案来解决我的问题here,它建议设置驱动程序的DesiredCapabilities,如下所示:
var capabilitiesInternet = new OpenQA.Selenium.Remote.DesiredCapabilities();
capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true);
IWebDriver webDriver = new InternetExplorerDriver(capabilitiesInternet);
唯一的问题是,我使用的是我能找到的最新版本的驱动程序,并且没有覆盖InternetExplorerDriver,它将DesiredCapabilities作为参数.
是否有一些新的或其他方式设置DesiredCapabilites而不是我使用的示例?
解决方法:
该设置将解决问题,但会引入一些微妙的问题.你没有正确设置IE的保护模式吗?这是正确的解决方案.
这里的指南生活在这里:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
基本上只需在IE中为每个区域关闭保护模式.
或者,如果您真的必须使用覆盖功能,那么您要么做两件事:
使用InternetExplorerOptions类.注意属性的名称,它给你一个很大的线索,使用它不是一个好主意.
var options = new InternetExplorerOptions;
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
var driver = new InternetEplorerDriver(options);
或使用RemoteWebDriver,它可以接受DesiredCapabilites实现的ICapabilities接口的任何实现:
var capabilities = new DesiredCapabilities("internet explorer", string.Empty, new Platform(PlatformType.Windows));
capabilities.SetCapability("ignoreProtectedModeSettings", true);
var webDriver = new RemoteWebDriver(capabilities);
原文地址:https://codeday.me/bug/20190529/1180814.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。