How can I disable save password popup in Selenium?(如何禁用 Selenium 中的保存密码弹出窗口?)
问题描述
我正在为 Java 使用 Selenium 版本 3.141.59,我想在初始化 Chrome 和 Firefox 的驱动程序时禁用密码弹出.
I am using Selenium version 3.141.59 for Java and I would like to disable password popup while initializing the driver for Chrome and Firefox.
我正在使用 Options 语法,因为 DesiredCapabilities 替代方案现已弃用.我的代码看起来像这样,但它不起作用:
I am using the Options syntax since the DesiredCapabilities alternative is now deprecated. My code look like this, but it is not working:
- 火狐
FirefoxOptions options = new FirefoxOptions();
options.addPreference("signon.rememberSignons", false);
webDriver = new FirefoxDriver(options);
- 铬
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("credentials_enable_service", false);
chromeOptions.setExperimentalOption("profile.password_manager_enabled", false);
webDriver = new ChromeDriver(chromeOptions);
如何在创建驱动程序之前将该选项添加到选项对象?
How can I add that option to the options object before creating the driver?
推荐答案
下面是java代码,对我有用.我将 selenium 3.3.1 与 selenium-chrome-driver 3.3.1 和 Java 8 一起使用.
Below are java code, which worked for me. I am using selenium 3.3.1 with selenium-chrome-driver 3.3.1 and Java 8.
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
options.addArguments("--disable-web-security");
options.addArguments("--no-proxy-server");
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
这篇关于如何禁用 Selenium 中的保存密码弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何禁用 Selenium 中的保存密码弹出窗口?
基础教程推荐
- JPA惰性列表上的流 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- Maven:无效的目标版本:10 2022-01-01
