【问题标题】:Internet Explorer Protective mode setting and Zoom levelsInternet Explorer 保护模式设置和缩放级别
【发布时间】:2018-09-25 18:56:19
【问题描述】:
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"
    };
    }
}

我在运行我的 selenium 脚本时尝试使用上述代码忽略缩放级别和保护模式设置,但该脚本在构建解决方案时显示错误。不知道我哪里出错了。

【问题讨论】:

    标签: c# selenium selenium-webdriver selenium-iedriver iedriverserver


    【解决方案1】:

    在使用 Selenium 3.xIEDriverServer 3.xInternet Explorer 时,您不能忽略 缩放级别 和 保护模式 设置。

    如果您查看Internet Explorer DriverRequired Configuration,则清楚地提到了以下几点:

    保护模式

    在 Windows Vista 或 Windows 7 上的 Internet Explorer 7 或更高版本上,您必须将每个区域的 保护模式 设置为相同的值。该值可以打开或关闭,只要每个区域都相同。要设置保护模式设置,您必须从“工具”菜单中选择“Internet 选项”,然后单击安全选项卡。对于每个区域,标签底部都有一个标记为启用保护模式的复选框。

    @JimEvans 在他的文章You're Doing It Wrong: IE Protected Mode and WebDriver 中明确提到:

    虽然使用该功能并不能解决根本问题。如果跨越保护模式边界,可能会导致非常意外的行为,包括挂起、元素位置不工作和点击不传播。为了帮助警告人们这个潜在问题,该功能被赋予了听起来很吓人的名字,例如 Java 中的 INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS.NET 中的 IntroduceInstabilityByIgnoringProtectedModeSettings。我们真的认为告诉用户使用此设置会在他们的代码中引入潜在的错误会阻止其使用,但事实并非如此。

    浏览器缩放级别

    浏览器缩放级别必须设置为 100%,以便可以将本机鼠标事件设置为正确的坐标。


    解决方案

    根据Internet Explorer DriverRequired Configuration

    • 将所有区域保护模式设置/取消设置为相同级别。
    • 浏览器缩放级别设置为100%

    【讨论】:

    • 好的,感谢您背后的逻辑解释。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多