Why Selenium Chrome Doesn't Show Save Password Dialog
In this article
Selenium Chrome does not show the save password dialog because it launches the browser using a clean, temporary user profile with the "Password Manager" feature disabled by default. This prevents automated scripts from being interrupted by unexpected browser pop-ups, which would otherwise cause the automation to crash or hang since Selenium cannot easily interact with native browser UI elements.
The Role of Chrome Profiles in Selenium
When you open Google Chrome manually, the browser loads your default user profile, which contains your history, cookies, extensions, and saved passwords. However, when a Selenium WebDriver instance starts, it creates a fresh, ephemeral profile in a temporary directory. This profile is designed to be a "blank slate" to ensure that tests are reproducible and not influenced by cached data or previous session states.
Because this temporary profile is new, it has no existing password database. More importantly, the ChromeDriver is configured to prioritize automation stability. If the "Save Password" prompt appeared every time a script logged into a site, the automation would stop because the prompt is part of the browser's native chrome (the outer shell), not the DOM (Document Object Model) of the webpage. Selenium is designed to interact with the HTML of the page, not the browser's own internal settings menus or pop-up alerts.
How Chrome's Password Manager Works with Automation
Chrome's password manager relies on a specific set of preferences stored in the user profile's Preferences JSON file. In a standard manual session, the credentials_enable_service and password_manager_enabled flags are set to true. In a Selenium-controlled session, these are often overridden or ignored to prevent the browser from attempting to sync with a Google account or trigger prompts that would obstruct the view of the web elements.
Furthermore, the browser is often launched with the --disable-save-password-bubble flag internally or via the driver's default capabilities. This ensures that the automation flow remains linear. If a developer needs to test the actual password saving functionality, they cannot rely on the default Selenium setup and must instead manipulate the browser's profile settings manually.
Ways to Enable Password Prompts in Selenium
While the default behavior is to hide these dialogs, there are specific methods to force Chrome to behave more like a standard user browser. This is typically done by passing specific ChromeOptions to the driver during initialization.
- Using a Persistent User Profile: Instead of a temporary profile, you can point Selenium to your actual Chrome user data directory. This allows the browser to access your existing saved passwords and triggers the password manager based on your actual settings.
- Modifying Preferences: You can use the
experimental_optionmethod to inject specific preferences into the browser profile before it launches. - Disabling Automation Flags: Some versions of Chrome detect the
enable-automationflag and automatically suppress certain UI elements. Using options to exclude these switches can sometimes restore native behavior.
Common Problems When Testing Authentication
Many developers mistake the absence of the save password dialog for a failure in their login script. In reality, the lack of a dialog is a sign that the driver is working as intended. However, this leads to other common challenges:
- Session Persistence: Because the profile is deleted after the session, users cannot test "Remember Me" functionality across multiple script executions without a persistent profile.
- CAPTCHA Triggers: Using a clean profile every time can make the browser look like a bot to security systems, increasing the likelihood of encountering CAPTCHAs.
- Cookie Handling: Without a saved profile, cookies are wiped every time the driver quits, meaning the script must perform a full login sequence for every single test case.
Comparison: Default Profile vs. Custom Profile
Choosing between the default Selenium behavior and a custom profile depends on the goal of the automation. The following table illustrates the trade-offs:
- Default Profile: High isolation, fast startup, no interference from existing cookies, but no saved passwords and no session persistence.
- Custom Profile: Realistic user environment, access to saved passwords, persistent sessions, but slower startup and risk of "Profile in use" errors if a manual Chrome window is already open.
Safety and Security Considerations
When attempting to enable the save password dialog by using a real user profile, security risks increase. A persistent profile contains sensitive data, including active session tokens and encrypted passwords. If the automation script is run on a shared server or a CI/CD pipeline, storing a real user profile on that machine can expose credentials to anyone with access to the file system.
It is generally recommended to use environment variables or secret managers to handle passwords during automation rather than relying on the browser's built-in password manager. This keeps the credentials out of the browser profile and ensures the tests remain secure and portable across different environments.
Frequently Asked Questions
Can I click the Save Password button using Selenium?
No, you cannot. The save password dialog is part of the browser's native UI, not the webpage's HTML. Since Selenium only interacts with the DOM, it cannot "see" or click buttons inside the browser's own toolbars or pop-up bubbles.
How do I stop Chrome from asking to save passwords in Selenium?
By default, Selenium already disables this. However, if you are using a custom profile and the prompt appears, you can add the --disable-save-password-bubble argument to your ChromeOptions to suppress it.
Does using incognito mode affect the password dialog?
Yes. If you launch Selenium with the --incognito flag, the browser will never offer to save passwords, as incognito mode is designed to discard all session data and credentials immediately upon closing.
Why does my script fail when the password dialog appears?
The dialog itself doesn't usually crash the script, but it can overlap other elements on the screen. If your script tries to click a button that is physically covered by the "Save Password" bubble, Selenium will throw an ElementClickInterceptedException.
Is there a way to check if a password was saved?
You cannot check this via standard Selenium commands. You would need to navigate the browser to chrome://settings/passwords and use Selenium to inspect the list of saved credentials on that specific internal page.