ChromeOptions AddUserProfilePreference

2020-07-29 02:24发布

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

2条回答
做自己的国王
2楼-- · 2020-07-29 02:33

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);
查看更多
Root(大扎)
3楼-- · 2020-07-29 02:38

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);
查看更多
登录 后发表回答