Anders Lindén
Anders Lindén

Reputation: 7303

"Save password for this website" dialog with ChromeDriver, despite numerous command line switches trying to suppress such popups

I am getting the "save password" dialog when creating a ChromeDriver like this:

var options = new ChromeOptions();

options.AddArguments("chrome.switches", "--disable-extensions --disable-extensions-file-access-check --disable-extensions-http-throttling --disable-infobars --enable-automation --start-maximized");
var driver = new ChromeDriver(options);

And navigates to a login form and submit it.

How do I get rid of the popup?

Upvotes: 8

Views: 13907

Answers (3)

Abdul Moiz Farooq
Abdul Moiz Farooq

Reputation: 325

Here is an implementation for Python users:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_experimental_option('prefs', {
    'credentials_enable_service': False,
    'profile': {
        'password_manager_enabled': False
    }
})
driver = webdriver.Chrome(chrome_options=chrome_options)

Upvotes: 2

Mikhail Ramendik
Mikhail Ramendik

Reputation: 1115

Here is this same solution adapted to Java, as used in my code. Adapting was non-trivial so sharing here in case other Java users read this:

        ChromeOptions chOption = new ChromeOptions();
        chOption.addArguments("--disable-extensions");
        chOption.addArguments("test-type");
        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("credentials_enable_service", false);
        prefs.put("profile.password_manager_enabled", false);
        chOption.setExperimentalOption("prefs", prefs);
        driver = new ChromeDriver(chOption);

Upvotes: 3

TopGun
TopGun

Reputation: 338

You need to add these preferences:

options.AddUserProfilePreference("credentials_enable_service", false);
options.AddUserProfilePreference("profile.password_manager_enabled", false);

So your final code will look like this:

 var options = new ChromeOptions();

 options.AddArguments("chrome.switches", "--disable-extensions --disable-extensions-file-access-check --disable-extensions-http-throttling --disable-infobars --enable-automation --start-maximized");
 options.AddUserProfilePreference("credentials_enable_service", false);
 options.AddUserProfilePreference("profile.password_manager_enabled", false);
 var driver = new ChromeDriver(options);

Upvotes: 15

Related Questions