WebDriver Chrome Browser: Avoid 'Do you want chrome to save your password' pop up
Asked Answered
C

8

19

Every time my webdriver tests login into the application, 'Do you want chrome to save your password' pop up appears.. Is there a way to avoid this??

Please help.

Thanks, Mike

Chet answered 30/4, 2013 at 13:43 Comment(1)
I've not come across it before, but could you not make a Chrome profile, disable the password manager in Chrome's settings, and use that profile for your tests?Caro
M
22

You need to configure the following chrome driver options:

chromeOptions: {
            prefs: {
                'credentials_enable_service': false,
                'profile': {
                    'password_manager_enabled': false
                }
            }
        }
Martijn answered 10/3, 2017 at 22:36 Comment(2)
Thanks for this! I added this to my conf.js, which I use with protractor on the command lineAlfredoalfresco
Worked as-is for ruby bindings as well.Aesthetics
F
17

I'm using Python, and this worked for me:

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)
driver.get('https://google.com')
Fasano answered 23/3, 2017 at 19:16 Comment(1)
chrome_options.add_experimental_option('prefs', { 'credentials_enable_service': False,}) is enoughClorindaclorinde
K
8

Just add these preferences to your chrome driver options:

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("password_manager_enabled", false); 
options.setExperimentalOption("prefs", prefs);
Kowalewski answered 22/3, 2017 at 9:49 Comment(0)
C
6

Yeah I just found the answer. I had to look into the Chrome's user data directory and find all the available chromeOptions the Preferences file. I'm on Centos 7 so the path looks like this:

~/.config/google-chrome/Default/Preferences

In order to remove the save password dialog, the config JSON chromeOptions section needs to have this:

chromeOptions: {
    prefs: {
        profile: {
            password_manager_enabled: false
        }
    }
}

It really makes me happy that I have finally found these options, however, it still is disappointing that google or selenium didn't list all the configurable preferences.

Columelliform answered 10/9, 2015 at 16:56 Comment(2)
I am wondering how you got this to work. What chromedriver version, chrome version, selenium version, etc? I keep getting a response the the "prefs" is not recognized.Aeroplane
Currently I'm using chromedriver 2.19 and selenium-server-standalone-2.47.1.jar. As another note, I am also able to get these settings to work with node's protractor module as well.Columelliform
A
4

Thanks to @karanvir Kang comment above, I added the following to my conf.js which I use when I call protractor. Example

protractor tests/conf.js --specs /tests/e2e/myspec.spec.js

And in my conf.js

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    seleniumPort: '4455',
    baseUrl: url,
    directConnect: false,
    //getMultiCapabilities: helper.getFirefoxProfile,
    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            prefs: {
                'credentials_enable_service': false,
                'profile': {
                    'password_manager_enabled': false
                }
            },
            args: [
                '--disable-cache',
                '--disable-application-cache',
                '--disable-offline-load-stale-cache',
                '--disk-cache-size=0',
                '--v8-cache-options=off'
            ]
        }
    },
Alfredoalfresco answered 29/3, 2017 at 21:37 Comment(0)
S
3

You can also start the chromedriver in incognito mode to stop the infobars from appearing. Please note that the experience will be like the incognito mode. Command will be

chrome.exe --incognito if you are running from command line you can add --incognito to chromeswitch array for executing from webdriver.

Splatter answered 3/5, 2013 at 3:58 Comment(0)
B
1

To provide a more complete picture, here is a working configuration for Watir in a Selenium Grid:

RSpec.configure do |config|
  config.before :all do
    capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
      chromeOptions: {
          prefs: {
              'credentials_enable_service': false,
              'profile': {
                  'password_manager_enabled': false
              }
          }
      }
    )

    @browser = Watir::Browser.new(
      :remote,
      url: "http://#{ENV.fetch('HUB_HOST')}/wd/hub",
      desired_capabilities: capabilities
    )
  end

  config.after :all do
    @browser&.close
  end
end

See a full proof of concept on github at docker-grid-watir.

Boulevard answered 23/5, 2017 at 21:35 Comment(0)
E
0

I know this is pretty old, it has been answered correctly and all. Just wanted to give my 5 cents. If you are using Robot Framework, bellow is the way to do it.

open-browser
    ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys
    ${cred_dict}=      Create Dictionary     credentials_enable_service=${FALSE}
    Call Method    ${chrome_options}    add_experimental_option    prefs     ${cred_dict}
    Create Webdriver     Chrome     chrome    chrome_options=${chrome_options}
Ethnomusicology answered 2/10, 2019 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.