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

求助:Selenium Python启动Microsoft Edge访客配置文件失败

启动Edge访客配置文件的正确方法

直接指定Guest Profile目录的方式行不通,因为Edge的访客模式并非使用固定的本地目录,而是通过专属参数触发临时隔离环境。你之前的写法会被Edge判定为普通用户配置启动,导致自动生成新的随机配置文件(比如Profile 2)。

正确的做法是使用--guest参数直接启动访客模式,代码示例如下:

from selenium import webdriver
from selenium.webdriver.edge.options import Options

# 配置Edge选项
edge_options = Options()
# 添加访客模式参数
edge_options.add_argument("--guest")

# 启动Edge访客浏览器
driver = webdriver.Edge(options=edge_options)
# 访问测试页面
driver.get("https://www.example.com")

如果需要模拟类似访客的隔离环境并保留临时数据(不推荐,访客模式本就是无痕迹设计),可以结合参数指定临时目录,但这本质上是自定义隔离配置而非原生访客模式:

edge_options.add_argument("--user-data-dir=C:\\Temp\\EdgeGuestTemp")
edge_options.add_argument("--profile-directory=Guest Profile")

但更推荐直接使用--guest参数,这才是Edge原生访客模式的正确启动方式。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 15:42:36