DEV Community

Shadab Ansari
Shadab Ansari

Posted on • Originally published at cosmocode.io on

How to disable insecure password warning in Firefox for Selenium?

If you use Selenium and Firefox version 52 or higher for running the automated tests and your development site does not use SSL, you will get the following warning when entering passwords on your login page This connection is not secure. Logins entered here could be compromised

Firefox will also open the URL https://support.mozilla.org/en-US/kb/insecure-password-warning-firefox?as=u&utm_source=inproduct in a new tab which takes the focus away from the page you are testing. It causes currently running Selenium tests to be failed.

The good news is

you can stop this warning and opening of the new tab by changing the Firefox preference security.insecure_field_warning.contextual.enabled to false

Java Code:

// Create a Firefox profile
FirefoxProfile profile = new FirefoxProfile();
//Set the preference to disable insecure password warning
profile.setPreference("security.insecure_field_warning.contextual.enabled", false);
//Pass the profile to the FirefoxDriver
WebDriver driver = new FirefoxDriver(profile);

// Start of test code

Python Code:

from selenium import webdriver
// Create a Firefox profile
profile = webdriver.FirefoxProfile()
//Set the preference to disable insecure password warning
profile..set_preference("security.insecure_field_warning.contextual.enabled", false);
//Pass the profile to the FirefoxDriver
driver = webdriver.Firefox(firefox_profile=profile);

// Start of test code

Top comments (0)