IE浏览器缩放非100%如何处理?

How to handle IE browser with Zoom other than 100%?

一些团队正在使用我们为其添加的 IE 功能,包括以下指定的功能: cap.setCapability("ignoreZoomSetting", true);

现在,如果我的缩放比例设置为 100%,我不会遇到任何执行问题。但是,如果我的缩放设置设置为 100% 以外的任何值,此功能有助于打开浏览器,但我的测试用例会失败,因为它无法在页面上找到所需的对象。有什么办法,我们可以在打开浏览器时将缩放级别更改为 100%,或者有其他关于如何处理这种情况的想法吗?

根据 Required Configuration for InternetExplorerDriver:

The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

此外,

For Windows 10, you also need to set "Change the size of text, apps, and other items" to 100% in display settings.

所以在使用InternetExplorerDriverInternetExplorer时你需要配置如下:

cap.setCapability("ignoreZoomSetting", true);
cap.setCapability("requireWindowFocus", false);
cap.setCapability("nativeEvents", false);

您可以在以下位置找到一些相关讨论:

因此,设置这些功能是最佳实践的一部分,如果使用这些配置,浏览器初始化会出现需要详细分析的问题。


然而,在这一点上值得一提的是:

On IE 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, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".

您可以在以下位置找到一些相关讨论:


tl;博士

几个相关的讨论:

Required Configuration 开始,您必须 将浏览器缩放级别设置为 100%,以便本机鼠标事件可以设置为正确的坐标。 DebanjanB 的答案有清楚地解释了这一点。除了他的方法,您可以通过设置 Internet 选项打开缩放级别为 100% 的 IE 浏览器:

Internet 选项>高级>勾选"Reset zoom level for new windows and tabs">点击应用>点击确定

然后当打开新的 windows 或标签时,它们应该每次都缩放 100%。