Wednesday 3 August 2016

Handle Windows Authentication Dialog in Automation - Selenium WebDriver

Windows Authentication dialogs are common when we are working in ODC environments.This would cause initial hickup for automation as the authentication pop-ups are out of DOM structure. This can handled in several ways like AutoIT, Sikuli, etc.

Below is one of the simplest way to handle.


Pass the credentials as part of the URL instead of plain URL.

Syntax:

http://username:password@abcd.com

Example:

String authUrl = http://username:password@abcd.com;

Use the above url in webdriver get command & launch the url.

WebDriver driver = new ChromeDriver();
driver.get(authUrl);


NOTE: 
1. If the application url consists path parameters, then use url till domain name in driver.get(url) then use driver.navigate(url/path) method
          
For Eg: http://www.example.com/page1
  driver.get("http://username:password@example.com");
 driver.navigate.To("http://www.example.com/page1");

2. The above syntax works for chrome & firefox. However, for Internet Explorer there are certain registry entries to make it work.

Refer the Section: 'How to disable the new default behavior for handling user information in HTTP or HTTPS URLs' in the below link.
https://support.microsoft.com/en-us/kb/834489




References:
https://www.cs.rutgers.edu/~watrous/user-pass-url.html
https://support.microsoft.com/en-us/kb/834489

No comments:

Post a Comment