Internet Explorer 保护模式设置和缩放级别 [英] Internet Explorer Protective mode setting and Zoom levels
问题描述
使用系统;使用 OpenQA.Selenium.IE;使用 OpenQA.Selenium.Remote;使用 OpenQA.Selenium;命名空间 CSharpAutomationFramework.Tests{公共类 BrowserSource{var options = new InternetExplorerOptions();options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;public bool IgnoreZoomLevel { 获取;放;}public bool IntroduceInstabilityByIgnoringProtectedModeSettings { get;放;}InternetExplorerDriver protectionmode = new InternetExplorerDriver(options);InternetExplorerOptions options = new InternetExplorerOptions();options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;InternetExplorerDriver zoom = new InternetExplorerDriver(zoomoptions);InternetExplorerOptions zoomoptions = new InternetExplorerOptions();options.IgnoreZoomLevel = true;静态字符串[] 浏览器 = {IE"};}}
我在运行 selenium 脚本时尝试使用上述代码忽略缩放级别和保护模式设置,但脚本在构建解决方案时显示错误.不知道我哪里出错了.
同时使用 Selenium 3.x、IEDriverServer 3.x 和 Internet Explorer您不能忽略缩放级别和保护模式设置.
如果您查看
@JimEvans 在他的文章 您做错了:IE 保护模式和 WebDriver 明确提到:
<块引用>尽管使用该功能并不能解决根本问题.如果跨越保护模式边界,可能会导致非常意外的行为,包括挂起、元素位置不起作用和点击未传播.为了帮助警告人们这个潜在的问题,该功能被赋予了听起来很吓人的名字,例如 Java 中的 INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS
和 中的 IntroduceInstabilityByIgnoringProtectedModeSettings
.网络.我们真的认为告诉用户使用此设置会在他们的代码中引入潜在的不良影响会阻碍其使用,但事实并非如此.
浏览器缩放级别
必须将浏览器缩放级别设置为 100%,以便将本机鼠标事件设置为正确的坐标.
解决方案
根据所需配置 Internet Explorer 驱动程序:
- 将所有区域的保护模式设置/取消设置为相同级别.
- 将浏览器缩放级别设置为100%
using System;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium;
namespace CSharpAutomationFramework.Tests
{
public class BrowserSource
{
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
public bool IgnoreZoomLevel { get; set; }
public bool IntroduceInstabilityByIgnoringProtectedModeSettings { get; set; }
InternetExplorerDriver protectivemode = new InternetExplorerDriver(options);
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
InternetExplorerDriver zoom = new InternetExplorerDriver(zoomoptions);
InternetExplorerOptions zoomoptions = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
static string[] Browsers = {
"ie"
};
}
}
I am trying to use the above code to ignore zoom levels and Protective mode settings while running my selenium script but the script is displaying errors on building the solution. Not sure where i am going wrong.
While working with Selenium 3.x, IEDriverServer 3.x and Internet Explorer you can't ignore Zoom Levels and Protective Mode settings.
If you look into the Required Configuration of Internet Explorer Driver the following points are clearly mentioned :
Protected Mode
On Internet Explorer 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings you have to choose "Internet Options" from the "Tools" menu and then click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled Enable Protected Mode.
@JimEvans in his article You're Doing It Wrong: IE Protected Mode and WebDriver clearly mentions :
Using the capability doesn't solve the underlying problem though. If a Protected Mode boundary is crossed, very unexpected behavior including hangs, element location not working, and clicks not being propagated, could result. To help warn people of this potential problem, the capability was given big scary-sounding names like
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS
in Java andIntroduceInstabilityByIgnoringProtectedModeSettings
in .NET. We really thought that telling the user that using this setting would introduce potential badness in their code would discourage its use, but it turned out not to be so.
Browser Zoom Level
The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
Solution
As per the Required Configuration of Internet Explorer Driver :
- Set/Unset the Protected Mode settings to the same level for all the Zones.
- Set the Browser Zoom Level to 100%
这篇关于Internet Explorer 保护模式设置和缩放级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!