问题
I have a Windows Service that runs a Team City Build agent on a Windows 7 OS.
This agent triggers NUnit tests which use the Selenium IE web drivers to execute a series of tests.
For the Selenium IE web drivers to work the protected mode for all zones needs to be set to the same value (either protected mode on or off).
The problem is the default settings for the Local System Account are invalid (some zones are running in protected mode, others are not).
Can anyone can tell me how to change the protected mode settings for either all users or the Local System Account user?
回答1:
Here is the solution (and I've been to every corner of the Internet in order to get this):
Fire up RegEdit
and go to this key:
HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
On my machine (Windows 7) the Local System account is S-1-5-18
. This might be the same for all versions of Windows, but I don't know about that.
In that registry key, there are five more keys 1, 2, 3, 4 and 5 - each representing a Zone.
For every zone, if there is a DWORD value with the name "2500", set its value to 0 to turn protected mode off. Note that you don't have to add it if it isn't there.
The value "2500" is supposed to control the tick box "Enable protected mode".
UPDATE (from an anon user):
A graphical way of doing the same is to ensure the "Interactive Services Detection" service (UI0Detect) is running (note that Windows 8/2012 and later need the HKLM\SYSTEM\CurrentControlSet\Control\Windows\NoInteractiveServices
registry key to be set correctly in order for the popup to appear) get hold of psexec
and run
psexec -si 0 "C:\Program Files\Internet Explorer\iexplore.exe"
In the popup click on View the message, then after the screen switches in Internet Explorer go to Tools -> Internet options | Security and check the Security level for each zone.
Happy UI testing!
回答2:
You could try disabling UAC, which will also disabled protected mode for all users in the system as well..
回答3:
The best description of a solution is this https://stackoverflow.com/a/30242504/1371989
回答4:
There is a setting on the IE WebDriver that tells it to ignore the protected mode settings. Judging by the name of the setting it might introduce some "instability", but I've had no problems with this approach:
var options = new InternetExplorerOptions();
// avoid the "Protected Mode must be set to the same value (enabled or disabled) for all zones" error
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
return new InternetExplorerDriver(options);
来源:https://stackoverflow.com/questions/7236247/ie-protected-mode-for-local-system-account