Difference between revisions of "How to handle the Firefox 48 security popup message "You are about to log in to the site ..." with selenium webdriver"

From Test Automation Wiki
Jump to: navigation, search
(Created page with "Often in test automation you have to test a website that has a proxy protection. Mostly this authentication is worked around by adding the credentials in the URL as following:...")
 
Line 22: Line 22:
 
     require 'selenium-webdriver'
 
     require 'selenium-webdriver'
 
     profile = Selenium::WebDriver::Firefox::Profile.new
 
     profile = Selenium::WebDriver::Firefox::Profile.new
    # Add your domain to the whitelist (Include HTTP[S]://), comma separated if more than 1.
+
     profile['network.http.phishy-userpass-length'] = 255
     profile['network.automatic-ntlm-auth.trusted-uris'] = "http://website.com"
 
 
     browser :firefox, :profile => profile
 
     browser :firefox, :profile => profile
 
   end
 
   end
Line 34: Line 33:
 
require 'selenium-webdriver'
 
require 'selenium-webdriver'
 
profile = Selenium::WebDriver::Firefox::Profile.new
 
profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.automatic-ntlm-auth.trusted-uris'] = "http://website.com"
+
profile['network.http.phishy-userpass-length'] = 255
 
WebDriver driver = new FirefoxDriver(profile);
 
WebDriver driver = new FirefoxDriver(profile);
 
</source>
 
</source>
  
 
[[Category:FAQ]]
 
[[Category:FAQ]]

Revision as of 18:28, 21 November 2016

Often in test automation you have to test a website that has a proxy protection. Mostly this authentication is worked around by adding the credentials in the URL as following: http://username:password@test.website.com/.

In FireFox 48 they have added an extra protection layer to warn the user that they are logging in to a protected URL:

You are about to log in to the site "(...)" with the username "(...)"

This new warning message will break all automation going to a protected domain.

White listing a domain for proxy authentication

Firfox also has a configuration setting network.automatic-ntlm-auth.trusted-uris that can be found going to the URL about:config. In this configuration you can add domains that you trust and thus will not give the warning message.

However, in test automation, a new clean browser is opened without any of your configurations to the browser. So these settings need to be defined before the browser starts.

Lapis Lazuli

Add the following code to your env.rb file:

LapisLazuli.Start do
  # If BROWSER is NIL, Lapis Lazuli will default to Firefox
  if !ENV['BROWSER'] || ENV['BROWSER'] == 'firefox'
    # Get Selenium to create a profile object
    require 'selenium-webdriver'
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile['network.http.phishy-userpass-length'] = 255
    browser :firefox, :profile => profile
  end
end

Selenium

require 'selenium-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.http.phishy-userpass-length'] = 255
WebDriver driver = new FirefoxDriver(profile);