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

前端 未结 8 1271
故里飘歌
故里飘歌 2020-12-11 01:07

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.

相关标签:
8条回答
  • 2020-12-11 01:19

    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}
    
    0 讨论(0)
  • 2020-12-11 01:23

    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);
    
    0 讨论(0)
  • 2020-12-11 01:24

    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.

    0 讨论(0)
  • 2020-12-11 01:26

    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.

    0 讨论(0)
  • 2020-12-11 01:31

    You need to configure the following chrome driver options:

    chromeOptions: {
                prefs: {
                    'credentials_enable_service': false,
                    'profile': {
                        'password_manager_enabled': false
                    }
                }
            }
    
    0 讨论(0)
  • 2020-12-11 01:32

    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'
                ]
            }
        },
    
    0 讨论(0)
提交回复
热议问题