本文介绍了“为该网站保存密码" ChromeDriver对话框,尽管有许多命令行开关试图抑制此类弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建这样的ChromeDriver时,出现保存密码"对话框:

I am getting the "save password" dialog when creating a ChromeDriver like this:

var options = new ChromeOptions();

options.AddArguments("chrome.switches", "--disable-extensions --disable-extensions-file-access-check --disable-extensions-http-throttling --disable-infobars --enable-automation --start-maximized");
var driver = new ChromeDriver(options);

然后导航至登录表单并提交.

And navigates to a login form and submit it.

我如何摆脱弹出窗口?

推荐答案

您需要添加以下首选项:

You need to add these preferences:

options.AddUserProfilePreference("credentials_enable_service", false);
options.AddUserProfilePreference("profile.password_manager_enabled", false);

因此您的最终代码将如下所示:

So your final code will look like this:

 var options = new ChromeOptions();

 options.AddArguments("chrome.switches", "--disable-extensions --disable-extensions-file-access-check --disable-extensions-http-throttling --disable-infobars --enable-automation --start-maximized");
 options.AddUserProfilePreference("credentials_enable_service", false);
 options.AddUserProfilePreference("profile.password_manager_enabled", false);
 var driver = new ChromeDriver(options);

这篇关于“为该网站保存密码" ChromeDriver对话框,尽管有许多命令行开关试图抑制此类弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 22:21