简体   繁体   中英

How to disable Insecure Password Warning in Firefox using Selenium Webdriver with Java

I am new to Selenium Webdriver. I am trying to test my application login page in Firefox. Every time while doing so I am getting insecure password warning (This connection is not secure. Logins entered here could be compromised).

This is coming when password is entered. How to disable that in selenium Webdriver using Java?

Currently I am using this code:

System.setProperty("webdriver.gecko.driver", driverPathFF); 
DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 
capabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true); 
driver = new FirefoxDriver(capabilities);

But it is not helping. I tried other ways found in related google search as well but no luck.

Please check the link for reference. Sceenshot

You may try to set preferences for firefox using Selenium. For example,

var firefoxOptions = new FirefoxOptions();
firefoxOptions.SetPreference("security.insecure_password.ui.enabled", false);
firefoxOptions.SetPreference("security.insecure_field_warning.contextual.enabled", false);

It represents values that can be changed manually by opening Firefox, typing about:config and finding the same options. It helped my tests to avoid the insecure login message.

Try Creating firefox profile like the below one,

profile = new FirefoxProfile()
profile.accept_untrusted_certs = True
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FireFoxDriver(dc);

A javascript way of doing this:

const {Builder} = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');

    var profile = new firefox.Profile();
    profile.setPreference("security.insecure_password.ui.enabled", false);
    profile.setPreference("security.insecure_field_warning.contextual.enabled", false);

    var options = new firefox.Options().setProfile(profile);
    var browserUnderTest = new webdriver.Builder()   
     .forBrowser('firefox')
     .setFirefoxOptions(options)
     .build();

If am right, I think there's a way to achieve that using selenium: Something of this nature;

var firefox = new FirefoxOptions();
firefox.SetPreference("security.insecure_password.ui.enabled", false);

Not too sure about that though! But just give it a shot!

In Java this worked for me

FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("security.insecure_field_warning.contextual.enabled", false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM