c# - 忽略 ChromeDriver 用户偏好

标签 c# google-chrome selenium selenium-webdriver selenium-chromedriver

我使用的是 Selenium webdriver 3.3 和 ChromeDriver 2.28(32 位)。我的从机是运行 Chrome 57 的 Windows 7。

当 Chrome 启动时,我尝试在 RemoteWebDriver 上使用 ChromeOptions,以使用参数“password_manager_enabled”禁用“保存密码”弹出窗口。

不过,好像一点作用都没有。我尝试了很多关于 ChromeOptions、JSON 字符串和简单字符串的变体,但都无济于事。

ChromeOptions cOpt = new ChromeOptions();
cOpt.addUserProfilePreference("profile.password_manager_enabled", false);
var capabilities = chromeOpts.ToCapabilities() as DesiredCapabilities;
// Add OS, Platform capabilities etc
string gridConnectionURL = "xxxx"
driver = new CustomRemoteDriver(new Uri(gridConnectionURL), capabilities, new TimeSpan(0, 5, 0));

有谁知道设置此首选项以使其起作用的“正确”方法?

最佳答案

你只需要更换

//cOpt.AddUserProfilePreference("password_manager_enabled", "false");
cOpt.AddUserProfilePreference("credentials_enable_service", false);
cOpt.AddUserProfilePreference("profile.password_manager_enabled", false);

关于c# - 忽略 ChromeDriver 用户偏好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42793277/

相关文章:

java - 调用maven项目的困惑

selenium - CreatePlatformSocket() 尝试通过网络路径访问 chromedriver 时返回错误 : An invalid argument was supplied. (0x2726)

c# - 如何确定 c# 中的 dns 更改?

c# - 当前上下文中不存在名称 '...'

c# - Control.Invoke问题(x是一个字段但是像方法一样使用)

c# - 如何通过属性编码为 ANSI 字符串?

javascript - 在 IntelliJ IDEA 中调试 JavaScript

google-chrome - 在 Chromium 中使用 WebCrypto 生成 RSA key 对

java - 无法将 WebDriver 实例转换为 JavascriptExecutor

selenium - Webdriver 中的 boolean 变量