How to handle windows site authentication in Web Driver?

I have started recently to work on test automation for a site that requires user authentication.

The authentication is not done through a login page but through integrated windows security.

This means that, before the site loads, a popup is displayed asking for the account's username and password.

The first idea that I had was to follow the standard way of working with popups in Selenium. 

You can see details on this link from StackOverFlow.com:

How to handle pop up in selenium webdriver using java


The code with popup handling did not work as the popup is not in the browser DOM when it is displayed.

The second idea was to populate the popup using another tool like AutoIt.

Not the best solution, though.

After more searching, I found something that works.

Instead of opening the page with this line

                  driver.get("http://www.samplesite.com/parameter");

use 

                  driver.get("http://username:password@www.samplesite.com/parameter");


When opening the site with the url updated with username and password, the authentication happens automatically and the site is loaded in the browser.





_____________________________________________________________________________


Do you want to learn more about test automation and Java?
I will start an SELENIUM online group training on October 15.
Please see the training details here.

Share this