Anyone that has worked with Selenium 2.0 WebDriver and IE will tell you how challenging it can be.
But there are three common issues that most people new to using Selenium IE face when getting started.
The 3 Selenium IE Issues
What I'm about to tell you is nothing new. In fact these issues are well documented on the Selenium IE site. However for some reason I still get asked the same question about the same issues over and over again. The three errors are:
- Protected Mode settings are not the same for all zones.
- The path to the driver executable must be set by the webdriver.ie.driver
- Unexpected error Browser zoom level
Protected Mode settings are not the same for all zones
The fix for this error should be self-explanatory but if you're just learning Selenium your brain might be too overwhelmed at first to be able to know what to do.
The issue is caused when your IE browser's Enabled Protected Mode option setting is set different for each of your Internet, Local internet, trusted sites and restricted sites zones. To fix in IE:
- Click on Tools>Internet Options
- Under Internet Options click on the Security tab
- In the Select a zone to view area click on the Internet zone
- In the Security level for this zone click on or off the Enable Protected Mode checkbox. Whichever one you choose, needs to be set for all the other zones. For this example check the box
- In the Select a zone to view area click on the Local intranet zone
- In the Security level for this zone click on the Enable Protected Mode checkbox.
- In the Select a zone to view area click on the Local intranet zone
- In the Security level for this zone click on the Enable Protected Mode checkbox.
- In the Select a zone to view area click on the Trusted sites zone
- In the Security level for this zone click on the Enable Protected Mode checkbox.
- In the Select a zone to view area click on the Restricted sites zone
- In the Security level for this zone click on the Enable Protected Mode checkbox.
Re-run your test and you should no longer get the protected mode error.
The path to the driver must be set by the webdriver.ie.driver
This error typically is caused by either not having the required IEDriverServer.exe on your local machine or not having it setup in your PATH environment variable.
- First thing to check is make sure that you have downloaded the Selenium Internet Explorer Driver Server the SeleniumHQ download area.
- Once you've downloaded the IEDriverServer you will want to add its location to your PATH environment variable. To do this:
- Right click on your window's Computer icon
- Select Properties from the menu
- Click on the Advanced system settings option
- In the System Properties dialog click on the Environment Variables button
- In the Environment Variables dialog under System variables click on the Path variable
- In the Edit System Variable dialog append the path to where you have the IEDriverServer.exe to the end of the Variable value. I downloaded mine to my Downloads directory on mylocal D driver
- Click ok and reboot your machine
Application not starting – Unexpected error Browser zoom level
If your application is not starting or you are just getting one or multiple InternetExplorerDriver Listening on port window mesages
than your IE browser's zoom level might be set to something other than 100%
To fix make sure that your Internet Explorer's Zoom property is set to 100%
Selenium IE 11 Issue
For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor :
isHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.
Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.
3 Selenium Issue – 3 Simple Fixes
Those are my top three common IE Selenium issues. The fixes for them are easy but can be frustrating if you are just learning Selenium with IE. Hope this helps
Thank you very much for posting this It is very useful for me
Great – thanks Mahesh! Glad it helped you
Its very much useful…I was struggled lot & I didn’t get specific answers anywhere.. Now I resolved IE webdriver issue.
Thanks for posting.
Cool – glad it helped!
This is manual setting for IE browser.
Is it possible to same ie setting by code or programitically?
You could but I don’t think its recommended: http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html
Hi Joe,
Just an observation about “The path to the driver must be set by the webdriver.ie.driver” – I found that if I included a space after the semi-colon when adding to the PATH setting on this computer (Windows 8.1) then my Git Bash instance didn’t transform the path into the correct format (i.e. it would come out as C:\Program Files (x86)\IEDriver32 instead of /c/Program Files (x86)/IEDriver32 ) – an Eagle-eyed colleague spotted the extra space I’d added between the semi-colon and the drive letter!
Cheers for the tips.
Thanks so much….it worked for me too..really frustrating but the solution is so simple…:)
Here is my Python code to automagically set the IE zoom level to 100% and reset it when the code finishes. It modifies the registry.
Be sure to include the code in any exception handling.
IEZoom
# Set the zoom value of IE
#
# In Windows Registry, Windows desktop magnification affects IE zoom factor.
# We use that to create the correct zoom factor
import winreg
MAGKEY = winreg.HKEY_CURRENT_USER
MAGSUBKEY = “Control Panel\Desktop\WindowMetrics”
MAGNAME = “AppliedDPI”
ZOOMKEY = winreg.HKEY_CURRENT_USER
ZOOMSUBKEY = “Software\Microsoft\Internet Explorer\Zoom”
ZOOMNAME = “ZoomFactor”
MAG100 = 96 # Desktop 100% magnification dpi value
ZOOM100 = 100000 # IE 100% zoom value @ 100% desktop magnification
def GetRegInfo( key, subkey, name):
with winreg.OpenKey( key, subkey) as read_key:
return winreg.QueryValueEx( read_key, name)
def GetWinMagInfo():
return GetRegInfo( MAGKEY, MAGSUBKEY, MAGNAME)
def GetIEZoomInfo():
return GetRegInfo( ZOOMKEY, ZOOMSUBKEY, ZOOMNAME)
def CalcIE100ZoomValue( mag_value):
return round( MAG100 * ZOOM100 / mag_value)
def SetRegInfo( key, subkey, name, type, value):
with winreg.OpenKey( key, subkey, access= winreg.KEY_SET_VALUE) as set_key:
winreg.SetValueEx( set_key, name, 0, type, value)
def SetIEZoomValue( zoom_value):
SetRegInfo( ZOOMKEY, ZOOMSUBKEY, ZOOMNAME, winreg.REG_DWORD, zoom_value)
# Module test
def main():
mag_info = GetWinMagInfo()
print( mag_info)
print( CalcIE100ZoomValue( mag_info[ 0]))
saved_zoom_info = GetIEZoomInfo()
print( saved_zoom_info)
print( CalcIE100ZoomValue( 144))
#SetIEZoomInfo( ( PERCENT100, 4))
#print( GetIEZoomInfo())
if __name__ == “__main__”:
main()