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

Python无驱动模式下如何禁用密码菜单(无需隐身/Chrome配置文件)

在Python无驱动环境中阻止Chrome密码菜单弹出的方案

你尝试的部分启动参数未生效,可通过以下几种方式组合解决:

1. 补充针对性的Chrome启动参数

在现有参数基础上,添加以下更直接的禁用项,组合使用通常能覆盖密码菜单的触发场景:

args = [
    f"--window-size={window_width},{window_height}",
    f"--window-position={x_position},{y_position}",
    "--disable-sync",
    "--no-first-run",
    "--no-default-browser-check",
    "--disable-backgrounding-occluded-windows",
    "--disable-renderer-backgrounding",
    "--disable-background-timer-throttling",
    "--disable-breakpad",
    "--disable-dev-shm-usage",
    f"--load-extension={EXTENSION_PATH}",
    # 新增的有效参数
    "--disable-password-manager",          # 彻底禁用密码管理器核心服务
    "--disable-form-autofill",             # 禁用表单自动填充(比--disable-autofill更精准)
    "--disable-features=PasswordManager,AutofillServerCommunication",  # 关闭密码管理器相关特性
    "--disable-credentials-service",       # 禁用凭证同步服务
    "--password-store=basic"               # 强制使用基础密码存储,避免系统级弹窗
]

2. 通过Chrome DevTools协议(CDP)动态禁用

如果你使用的是Pyppeteer、Playwright这类无驱动库,可以通过CDP命令在浏览器启动后动态修改设置,从底层关闭密码提示:
以Pyppeteer为例,在页面初始化前执行:

# 禁用当前域名的密码管理器权限
await page._client.send('Browser.setPermission', {
    'origin': page.url,
    'permission': 'passwordManager',
    'setting': 'denied'
})

# 直接关闭密码管理器Web特性
await page._client.send('Emulation.setDisabledWebFeatures', {
    'disabledFeatures': ['PasswordManager']
})

3. 使用临时空配置目录(无需保留配置)

若上述参数仍无效,可以指定一个临时空目录作为用户数据目录,既不用默认配置文件,也不用隐身模式:
在args中添加:

"--user-data-dir=/tmp/chrome_temp_profile",  # 临时目录,关闭后可删除
"--profile-directory=Default"

这种方式会让Chrome启动一个全新的临时环境,默认不会启用密码保存提示,同时你可以继续加载指定扩展。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 22:00:10