ChromeOptions AddUserProfilePreference [英] ChromeOptions AddUserProfilePreference

查看:928
本文介绍了ChromeOptions AddUserProfilePreference的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Java的Webdriver 3.3.1。我试图禁用弹出窗口要求保存密码。基于搜索结果我需要使用
ChromOptions.AddUserProfilePreference(,)
但是,没有AddUserProfilePreference
唯一的add方法是addArguments。

I am using Webdriver 3.3.1 with Java. I am trying to disable the pop-up asking to save passwords. Based on search results I need to use ChromOptions.AddUserProfilePreference("","") However, there is no AddUserProfilePreference the only add method is addArguments.

我正在使用Eclipse Neon.2和Java 1.8

I am using Eclipse Neon.2 and Java 1.8

推荐答案

使用ChromeDriver 2.28& Selenium 3.3.1,以下工作原理:

With ChromeDriver 2.28 & Selenium 3.3.1, the following works:

final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
final ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
Map<String, Object> prefs = new LinkedHashMap<>();
prefs.put("credentials_enable_service", Boolean.valueOf(false));
prefs.put("profile.password_manager_enabled", Boolean.valueOf(false));
chromeOptions.setExperimentalOption("prefs", prefs);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);

这篇关于ChromeOptions AddUserProfilePreference的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆