B Internet Explorer And Protected Mode - essenius/FitNesseFitSharpSelenium GitHub Wiki

Internet Explorer and Protected Mode

When using Internet Explorer (or Edge in Internet Explorer mode), Selenium requires all Internet Explorer security zones to have the same setting for Protected Mode. The issue behind this workaround cannot be resolved by Selenium; it is due to the way that Internet Explorer handles switching between protected and unprotected modes: it switches processes under the hood, and the browser driver cannot detect that. The only way around it is making sure that such a switch does not occur, and therefore the protected mode settings for all zones need to be the same.

Unfortunately, this is not always compatible with corporate environments, which tend to lock down these settings to different values. Quite often, the Intranet zone defaults to unprotected, and the Internet zone to protected. The fixture has a function to check whether the protected mode settings are compatible for testing with Internet Explorer. It throws a StopTestException (causing the rest of the test not to be executed) if the setting is incorrect. Here is an example:

|Script     |Selenium             |
|Protected Modes Are Equal        |
|set browser|internet explorer    |
|open       |http://www.google.com|

If this should be the case, then the best course of action is to convince the proper authorities in your company that switching on Protected Mode on for the Intranet and Trusted zones (the ones that are most likely to be off) makes the setup more secure, so that shouldn’t be a concern. These settings are controlled via several key trees in the registry, allowing for policies to overrule individual settings. It will use the first value that it finds, in the following order of evaluation (HKLM = HKEY_LOCAL_MACHINE; HKCU = HKEY_CURRENT_USER):

  1. HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
  2. HKCU\\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
  3. HKCU\\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
  4. HKLM\\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones

In the Zones key, you will find keys 0 to 4, representing each of the zones. In those keys, you might find a DWORD named 2500. Value 0 means enabled, and 3 means disabled. If the key is not there, Internet Explorer will look at the next value. An example is shown below.

Zone Protection in RegEdit