有没有办法使用 Selenium 处理 Google Chrome 中的更改密码提示?

问题描述 投票:0回答:1

我正在尝试在 Google Chrome 中使用 Selenium-Java 自动化一个电子商务网站,我使用用户名和密码进行登录。身份验证成功后,将打开主页。此浏览器弹出窗口(更改您的密码 - 您刚刚使用的密码在数据泄露中被发现。Google 密码管理器建议立即更改您的密码)正在并行显示,我打算抑制/处理它,这样它就不会'根本不要出现,否则就会关闭。我研究过使用 ChromeOptions,但无法找出要传递的正确参数。请问有人可以帮忙吗?

在此输入图片描述

selenium-webdriver
1个回答
0
投票

这对我有用:https://issues.chromium.org/issues/42323769#comment23

final Map<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("credentials_enable_service", false);
chromePrefs.put("profile.password_manager_enabled", false);
chromePrefs.put("profile.password_manager_leak_detection", false); // <======== This is the important one

final ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("prefs", chromePrefs);
© www.soinside.com 2019 - 2024. All rights reserved.