Handling windows authentication pop-up in selenium

Selenium does not handle windows pop-ups, applications that uses windows authentication requires login details in the windows pop-up.

You can solve the above problem in 2 ways:

1. sending username/password in url itself.
2. sending username/password from an external source.

Sending username/password from an external source:

Step 1: Download AutoIT tool from
"http://www.autoitscript.com/site/autoit/downloads/"
(AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting)
Step 3: The below are the AutoIt script to send the authentication details:
WinWaitActive("Authentication Required","","20")
If WinExists("Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf
Save the above code with extension .au3 and then use “compile script to .exe” tool to convert it to an exe and call it in the selenium code.

Selenium webdriver code to call the above exe:

Runtime run = Runtime.getRuntime();
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "https://url/");
Process pp=run.exec("path to the .exe file");



No comments:

Post a Comment