问题描述
我正在IE11上使用webdriver.并且每个硒都有一组需要在IE11中运行的必需设置,其中之一是在Internet选项>高级>安全中禁用增强的保护模式"(与Internet选项>安全中的已启用保护模式不同)
I am using webdriver on IE11. And per selenium there are a set of required setting to run in IE11 one of them is to disabled "enhanced protected mode" in Internet Option > Advanced > Security (not the same as the enabled protected mode in Internet Option > Security)
问题是,我的组策略禁用了这些字段,这意味着我不能在不要求更改组策略的情况下将其关闭.我想知道是否有IE功能或选项可以解决此问题,例如Internet选项>安全启用保护模式设置的caps ['ignoreProtectedModeSettings'] = True =
The problem is, my group policy's has those field disabled, meaning I cannot turn them off without requesting for a group policy change. I was wondering if there is a IE capability or option out there that can work around this issue like the caps['ignoreProtectedModeSettings'] = True for the Internet Option > Security Enable Protection Mode setting
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
推荐答案
请尝试使用 InternetExplorerOptions 对象,并将 IntroduceInstabilityByIgnoringProtectedModeSettings 属性在C#应用程序,代码中设置为true如下:
Please try to use the InternetExplorerOptions object and set the IntroduceInstabilityByIgnoringProtectedModeSettings property to true in C# application, code as below:
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应用程序,请尝试使用以下代码:
If you application is a Java application, try to use the following code:
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);
来自此链接的代码.
这篇关于Webdriver禁用增强的保护模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!