Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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?

like image 378
Anders Lindén Avatar asked Apr 05 '17 06:04

Anders Lindén


People also ask

Can websites detect Chromedriver?

Can a website detect when you are using selenium with chromedriver? Yes. Also, what I haven't experimented with is older selenium and older browser versions - in theory, there could be something implemented/added to selenium at a certain point that Distil Networks bot detector currently relies on.

How do I disable Chromedriver?

browser. close() will close only the current chrome window. browser. quit() should close all of the open windows, then exit webdriver.

Can Chromedriver work without Chrome?

The answer is No. You have to have the chrome application inside your computer.

Is Chromedriver different from Chrome?

ChromeDriver is a separate executable that Selenium WebDriver uses to control Chrome. It is maintained by the Chromium team with help from WebDriver contributors. If you are unfamiliar with Selenium WebDriver, you should check out the Selenium site.


2 Answers

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);
like image 153
TopGun Avatar answered Nov 02 '22 23:11

TopGun


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);
like image 33
Mikhail Ramendik Avatar answered Nov 03 '22 01:11

Mikhail Ramendik