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 中的保存密码弹出窗口?
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
