While setting the IgnoreZoomLevel property allows you to open the browser without error, the test will find no elements at a zoom level other than 100%.
Sending Ctrl+0 will also not always have the expected result, depending on your systems DPI setting. If you have selected Medium (120 dpi) or Larger (144 dpi) (Windows 7 settings) Ctrl+0 will set the zoom to 125% or 150%.
A workaround I found is to set the zoom level according to the DPI settings by editing the setting, before opening IE, in the registry. This does not require administrator rights since everything is located under HKEY_CURRENT_USER.
This is my little helper class I came up with. (C#)
using Microsoft.Win32;
namespace WebAutomation.Helper
{
public static class InternetExplorerHelper
{
private static int m_PreviousZoomFactor = 0;
public static void SetZoom100()
{
// Get DPI setting.
RegistryKey dpiRegistryKey = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop\\WindowMetrics");
int dpi = (int)dpiRegistryKey.GetValue("AppliedDPI");
// 96 DPI / Smaller / 100%
int zoomFactor100Percent = 100000;
switch (dpi)
{
case 120: // Medium / 125%
zoomFactor100Percent = 80000;
break;
case 144: // Larger / 150%
zoomFactor100Percent = 66667;
break;
}
// Get IE zoom.
RegistryKey zoomRegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\Zoom", true);
int currentZoomFactor = (int)zoomRegistryKey.GetValue("ZoomFactor");
if (currentZoomFactor != zoomFactor100Percent)
{
// Set IE zoom and remember the previous value.
zoomRegistryKey.SetValue("ZoomFactor", zoomFactor100Percent, RegistryValueKind.DWord);
m_PreviousZoomFactor = currentZoomFactor;
}
}
public static void ResetZoom()
{
if (m_PreviousZoomFactor > 0)
{
// Reapply the previous value.
RegistryKey zoomRegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\Zoom", true);
zoomRegistryKey.SetValue("ZoomFactor", m_PreviousZoomFactor, RegistryValueKind.DWord);
}
}
}
}
I came up with the values comparing the ZoomFactor value in the registry at different system DPI settings with IE zoom set to 100%. There are more than 3 DPI settings in newer Windows versions, so you need to extend the class if you need those.
You could also modify this to calculate any zoom level you want but that was just not relevant for me.
I just call InternetExplorerHelper.SetZoom100();
before opening IE and InternetExplorerHelper.ResetZoom()
after closing it.