gpt4 book ai didi

c# - Internet Explorer 保护模式设置和缩放级别

转载 作者:行者123 更新时间:2023-11-30 23:03:37 25 4
gpt4 key购买 nike

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 脚本时忽略缩放级别和保护模式设置,但该脚本在构建解决方案时显示错误。不确定我哪里出错了。

最佳答案

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

如果您查看 Required ConfigurationInternet Explorer Driver明确提到了以下几点:

保护模式

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

ProtectedModeSettings

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

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 and IntroduceInstabilityByIgnoringProtectedModeSettings 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.

浏览器缩放级别

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


解决方案

根据 Required ConfigurationInternet Explorer Driver :

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

关于c# - Internet Explorer 保护模式设置和缩放级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49850465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com