smriti
smriti

Reputation: 1144

Automate the manual steps for IE browser working with InternetExplorerDriver

I need your help on automating some steps while working with InternetExplorerDriver webdriver.

Following is my code:

File file =new File("C:\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
driver = new InternetExplorerDriver(caps);

While executing this I am getting this exception.

Caused by: org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1.29 seconds

After googling I got a help to change some IE setting manually. http://jimevansmusic.blogspot.in/2012/08/youre-doing-it-wrong-protected-mode-and.html

My problem is – I have to run one end to end suite, where system will allocate one window box runtime and start the test, so there is no manual interaction in between, My all tests are failing with above exception.

Is there any way to bypass these manual steps or put some logic/API in Java/Selenium Code?

FYI- I tired below code ignore the security to true. Its not helping me at all/ getting same exception.

capab.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

Upvotes: 0

Views: 939

Answers (1)

Arran
Arran

Reputation: 25076

All of the settings for each "level" in Internet Explorer are stored in the registry, including the protected mode settings.

If you open up the registry editor, and navigate to:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones

Within this registry key there will be 5 subkeys, each labelled 0 through to 4. These map to the "zones" or "site levels" within your "Internet Options" control panel applet.

Microsoft have a slightly-outdated piece of documentation about what each Zone relates to, and what each setting within these zones relate to.

You should be able to see that there is a particular DWORD value that represents the Protected Mode settings:

2500     Turn on Protected Mode [Vista only setting] #

The values that are important here are 0 and 3. 0 = Protected Mode is on, 3 = Protected Mode is off.

There is a little trick here though. It isn't always present. This is because Windows has defaults it uses if the value isn't present at all.

The defaults are that the Internet and Restricted Sites zones have the setting turned on, unless you are using IE7 in which case the Local Intranet zone also has it turned on.

So, what can you do? You have two choices. You are already using Java and therefore could simply poke around to find out how to edit the registry using Java or you could quite easily do the same thing with pure old batch files, using the REG.EXE tool (documentation says "Windows XP" - ignore it, the tool just hasn't had any changes since Windows XP).

Upvotes: 2

Related Questions