You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Selenium启动Internet Explorer失败,寻求解决方案

问题描述

尝试通过Selenium创建Internet Explorer浏览器实例时,无法创建会话并抛出如下错误:

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.

常规解决方案要求在「Internet选项->安全」面板中配置Protected Mode复选框,但我的界面中没有该选项。其他浏览器可正常运行,但使用场景必须依赖Internet Explorer。


解决方案

1. 代码层面跳过Protected Mode检查

初始化IE Driver时,添加ignoreProtectedModeSettings参数强制跳过该校验,无需修改系统设置:

from selenium import webdriver
from selenium.webdriver.ie.options import Options

ie_options = Options()
ie_options.add_argument("ignoreProtectedModeSettings")
driver = webdriver.Ie(options=ie_options)

也可通过DesiredCapabilities配置:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.INTERNETEXPLORER.copy()
caps['ignoreProtectedModeSettings'] = True
driver = webdriver.Ie(desired_capabilities=caps)

2. 检查组策略限制

无Protected Mode复选框通常是系统组策略禁用了该设置,可通过以下步骤排查:

  • 按下Win+R输入gpedit.msc打开组策略编辑器
  • 导航至「用户配置->管理模板->Windows组件->Internet Explorer->Internet控制面板->安全页」
  • 查看Internet、本地Intranet、受信任站点、受限制站点四个区域的「启用保护模式」策略,确保所有区域的设置一致(全部启用或全部禁用)
  • 若策略为「未配置」,可手动设置统一状态后重启电脑

3. 重置IE浏览器设置

  • 打开IE,点击右上角齿轮图标→「Internet选项」
  • 切换到「高级」选项卡,点击「重置」
  • 勾选「删除个人设置」后确认重置,完成后重启电脑再尝试启动IE Driver

4. 匹配IEDriverServer与IE版本

确保使用的IEDriverServer版本与本地IE浏览器版本完全匹配,替换对应版本的驱动文件后重试。

内容的提问来源于stack exchange,提问作者subham chomal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 04:56:03