0

Before running any web tests I want to ensure that the IE11 is on zoom level 100%.

Is there any way to programmatically reset the zoom level to 100%? I'm using C# and would prefer an official Microsoft API, if there is none, I guess I need to set some registry or configuration setting.

Note: I'm not looking for a solution for resetting the zoom level using JavaScript or HTML!

D.R.
  • 20,268
  • 21
  • 102
  • 205
  • what about [SendKeys](http://stackoverflow.com/q/15292175/2596334)? `alt-v, z, 0` – Scott Solmer Oct 21 '14 at 14:02
  • `ctrl-0` would be even shorter – Raidri Oct 21 '14 at 14:08
  • Don't know if that's a good solution, however, unfortunately not possible at all: my web testing framework already throws an exception on IE-start if the zoom-level is not 100%. So no time for me to do any SendKeys-stuff. – D.R. Oct 21 '14 at 14:08

3 Answers3

0

Well then would not the right thing be to detect that the zoom level isn't 100% and then reset it - rather than letting the application crash because it assumes the zoom is 100%?

Minok
  • 522
  • 4
  • 9
0

Close the browser with zoom setting as 100%

Go to RegEdit

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom
Change ResetZoomOnStartup2 value to 0 (It doesn't default the zoom setting to the regular one)

OR

In windows 10, go to display settings and change the scaling to 100%

That should set the basic zoom to 100% in IE

Logovskii Dmitrii
  • 2,629
  • 4
  • 27
  • 44
0

You can use the following code:

 string registryKey = @"Software\Microsoft\Internet Explorer\Zoom";
 var regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKey, true);
 if (regKey != null)
 {
     regKey.SetValue("ZoomFactor", unchecked((int)0x00100000), RegistryValueKind.DWord);
 }