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
Revision as of 14:49, 10 August 2016 by Gijsp (talk | contribs) (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:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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
    # Add your domain to the whitelist (Include HTTP[S]://), comma separated if more than 1.
    profile['network.automatic-ntlm-auth.trusted-uris'] = "http://website.com"
    browser :firefox, :profile => profile
  end
end

Selenium

require 'selenium-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.automatic-ntlm-auth.trusted-uris'] = "http://website.com"
WebDriver driver = new FirefoxDriver(profile);