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

如何使用C# Selenium禁用Chrome浏览器的「保存地址」弹窗

解决Chrome浏览器「保存地址」弹窗问题

针对你遇到的C# Selenium自动化时Chrome弹出「保存地址」弹窗的问题,之前的配置未命中地址保存提示的核心控制项,可通过以下配置解决:

有效配置代码

IWebDriver driver;
ChromeOptions chromeOptions = new ChromeOptions();

// 禁用地址自动填充功能,阻止保存地址提示
chromeOptions.AddUserProfilePreference("autofill.profile_enabled", false);
// 禁用自动填充相关的弹窗提示
chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.autofill", 2);

// 保留原有配置中有用的项
chromeOptions.AddArgument("--disable-notifications");
chromeOptions.AddAdditionalChromeOption("useAutomationExtension", "false");

new WebDriverManager.DriverManager().SetUpDriver(new ChromeConfig());
driver = new ChromeDriver(chromeOptions);

关键配置说明

  • autofill.profile_enabled: 直接关闭Chrome的地址自动填充功能,从根源上消除保存地址的触发逻辑
  • profile.default_content_setting_values.autofill: 将自动填充的内容设置设为"阻止"(值2对应阻止),进一步拦截相关提示弹窗

你之前使用的--disable-popup-blocking等参数针对的是普通网页弹窗,而「保存地址」是Chrome内置的自动填充提示,需要针对autofill相关的用户配置项设置才能生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 01:16:10