2014-08-08

Most of us may wonder what HTTP Authentication is? Often we face a situation where a window dialogue is popped up asking for a username and password when we try to open an application URL. This security is referred as HTTP Authentication or NTLM Authentication.

I did some research on it and found out a way to work this out. This technique may be known to many, but certainly it will be helpful to the freshers and those who are still figuring out a solution for this scenario.
Let us consider an example:

Application URL: http://abc.com/

NTLM username: user

NTLM password: pass

NTLM username and password are the credentials to be used for authentication dialogue box.

Below are the ways to handle this in different browsers:

For Firefox:

In Firefox we simply need to handle it as:

driver = new FirefoxDriver();

driver. Navigate().GoToUrl(“http://user:pass@abc.com/”);

For Internet Explorer:

In internet explorer the new format of URL is not default accepted. Here, we will first make some settings in registry.

For 32 bit OS:

Open ‘regedit’ from run command.

Go to ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE‘

Create two new DWORDS iexplore.exe and explorer.exe and make sure their values are 0.

For 64 bit OS:

Open ‘regedit’ from run command.

Go to ‘HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE‘

Create two new DWORDS iexplore.exe and explorer.exe and make sure their values are 0.

Bingo! Now you are ready to use NTLM credentials in URL for internet explorer.

Handle DOMAIN with authentication:

There are times, when we need to provide domain details too in HTTP authentication. If we try to use the updated URL ‘http://domain\user:pass@abc.com’, we will get an error.

Therefore to handle this situation, use URL in format like http://domain%5cuser:pass@abc.com

Happy Testing!

The post HTTP Authentication in Selenium or Webdriver appeared first on The Official 360logica Blog.

Show more