简体   繁体   English

无法从 Selenium 启动 IE - 所有区域的保护模式设置都不相同

[英]Unable to Launch IE from Selenium - Protected Mode settings are not the same for all zones

I am trying to lauch IE using below code:我正在尝试使用以下代码启动 IE:

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:还尝试重置即设置:

在此处输入图像描述

You should go to each zone screen (Internet, Local Internet, Trusted Sites, Restricted Sites) and set for each the same level.您应该 go 到每个区域屏幕(Internet、本地 Internet、受信任站点、受限制站点)并为每个相同级别设置。 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.正如错误消息所示,Selenium 要求它们相同。

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.更新:如果其中一个区域的滑动条被禁用,您可以尝试以管理员身份运行 IE,以查看它是否以这种方式启用。

If this doesn't work, set all other zones to the same value, as the zone that you can't change.如果这不起作用,请将所有其他区域设置为与您无法更改的区域相同的值。

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.我无法通过手动更改设置来解决这个问题(其中很少有人被禁用,包括复选框),但下面的 VBA 代码对我有用。

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!只需将此代码复制到记事本中并使用.vbs 扩展名保存并双击!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium IE 保护模式设置对所有区域都不同。 我的 IE 中的区域都被禁用了 - Selenium IE protected mode settings are not the same for all zones. The zones in my IE are all disabled Selenium NoSuchDriverError IE 保护模式 VBA - Selenium NoSuchDriverError IE Protected mode VBA 无法在selenium webdriver中启动IE浏览器 - Unable to launch IE browser in selenium webdriver Ruby cucumber:如何在Selenium WebDriver中忽略IE保护模式错误? - Ruby cucumber: How to ignore IE protected mode error in Selenium WebDriver? 由于安全策略,Selenium IEDriverServer无法配置保护模式 - Selenium IEDriverServer unable to configure protected mode due to security policy 如何使用 Selenium Java 在 IE 模式下启动 Microsoft Edge - How to launch Microsoft Edge in IE mode using Selenium Java 无法从Selenium Webdriver启动IE / Chrome - Not able to launch IE/Chrome from Selenium Webdriver 使用IEDriverServer 3.9.0.0运行硒时无法启动IE 11 - Unable to launch IE 11 when running selenium with IEDriverServer 3.9.0.0 无法启动chrome,即在节点上使用Selenium网格 - Unable to launch chrome, ie on node using Selenium grid 如何通过 Selenium 和 Java 使用 setCapability() 忽略 Internet Explorer 的受保护模式设置? - How to ignore protected Mode Settings for Internet Explorer using setCapability() through Selenium and Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM