1

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.

I am using Eclipse Neon.2 and Java 1.8

tlvranas
  • 33
  • 1
  • 5

2 Answers2

8

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);
Anerty
  • 211
  • 1
  • 8
4

Add the below chrome options:

Map<String, Object> prefs =new HashMap<String, Object>();
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-extensions");
prefs .put("credentials_enable_service", false);
prefs .put("profile.password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
Anuj Teotia
  • 1,303
  • 1
  • 15
  • 21
  • If you found this (or any) answer helpful, please upvote it. If this answered your question, please mark it as the accepted answer. Thanks! – Anuj Teotia Mar 30 '17 at 16:08
  • Hi, Where can I get the complete list of values that I can use with prefs.put. Thanks – Anish Pillai Apr 11 '17 at 01:38
  • I don't have the complete list but you can do many things using prefs.put. Some of them are : 1. Set a Chrome preference **prefs.put("profile.default_content_settings.popups", 0);** 2. Set Binary **prefs.put("binary", "/usr/lib/chromium-browser/chromium-browser");** 3. Download directory path **prefs.put("download.default_directory", refPath);** 4. two are already given in the solution. Thanks! – Anuj Teotia Apr 11 '17 at 05:38