Reputation: 760
I am trying to lauch IE using below code :
driver = webdriver.Ie("IEDriverServer.exe")
driver.get("https://www.google.com")
This was working earlier, But i tried changing the security level in internet options, and after that it is giving below error:
selenium.common.exceptions.SessionNotCreatedException: Message: 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.
I saw many people mentioning this issue and saying that this can be fixed by using Default levels in security tab. I have tried this but still i am getting same issue. Also stried resetting ie settings :
Upvotes: 1
Views: 2495
Reputation: 760
I was not able to fix the issue by manually changing the setting(few of them were disabled for me including the checkbox), but the below VBA code did the trick for me.
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set ScriptMe=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
'Disable protected mode for local intranet'
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\"
strValueName = "2500"
dwValue = 0
ScriptMe.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
'Disable protected mode for trusted pages'
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2\"
strValueName = "2500"
dwValue = 0
ScriptMe.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
'Disable protected mode for internet'
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\"
strValueName = "2500"
dwValue = 0
ScriptMe.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
'Disable protected mode for restricted sites'
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4\"
strValueName = "2500"
dwValue = 0
ScriptMe.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
msgbox "Protected Mode Settings are updated"
Just copy this code into notepad and save it with .vbs extension and do a double click!
Upvotes: 1
Reputation: 1118
You should go to each zone screen (Internet, Local Internet, Trusted Sites, Restricted Sites) and set for each the same level. For example "Medium".
When you click on "Reset all zones to default", this makes some zones Medium, some High, so they are not the same any more. And as the error message suggests, Selenium requires them to be the same.
Update: If for one of the zones the slide bar is disabled, you can try to run IE as Administrator, to see if this way it gets enabled.
If this doesn't work, set all other zones to the same value, as the zone that you can't change.
Upvotes: 0