1

Below is my AutoIt script (UI3_Authentication.au3) for handling a Windows authentication pop up.

AutoItSetOption("WinTitleMatchMode","2")  
WinWait("Authentication Required")   
$title = WinGetTitle("Authentication Required") ; retrives whole window title   
$UN=WinGetText($title,"User Name:")  
ControlSend($title,"",$UN,"test");Sets Username  
$PWD=WinGetText($title,"Password:")  
Send("{TAB 1}")  
ControlSend($title,"",$PWD,"test1234");Sets PWD  
Send("{ENTER}")  

Below is my Selenium code call to the above AutoIt exe file.

package tests;

import java.io.IOException;  
import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;  

public class Handling_Windows_Based_Prompt {

public static void main(String[] args) throws IOException{  
WebDriver c1 = new FirefoxDriver();  
c1.get(“http://www.test.com”);  
        Runtime.getRuntime().exec("C:\\POM_Newdemo\\EF_Automation_Demo\\UI3_Authentication.exe");

}  
}

When I run the above Selenium file, it opens up the page and authentication pop up. But it is not inserting username and password; it waits for user input instead.

3 Answers 3

3

I resolved this. Actually, it was my bad. Previously, my code was like this:

c1.get(“http://www.test.com”);  
    Runtime.getRuntime().exec("C:\\POM_Newdemo\\EF_Automation_Demo\\UI3_Authentication.exe");

I Added autoit code before my get() as follows, and it worked:

Runtime.getRuntime().exec("C:\\POM_Newdemo\\EF_Automation_Demo\\UI3_Authentication.exe");
c1.get(“http://www.test.com”);
0

This works with my ChromeDriver. Hope it will be helpful

WinWait("data:, - Google Chrome","","10") ; this is the name of the window, according to AUTOIT v3 window info
If WinExists("data:, - Google Chrome","") Then
WinActivate("data:, - Google Chrome") ; set control to the window for proxy authentication
Send("putUsernameHere{TAB}") ; send username and press TAB
WinActivate("data:, - Google Chrome") ; again set control to our window, in case that we have clicked somewhere else
Send("putPasswordHere{ENTER}") ; send the password and press enter
EndIf
0

I faced the same problem. AutoIt works well with selenium if it is running in an "open" desktop. If I use a Virtual Machine with a open session(seeing what is happening), even minimized, it works fine, but if I close the remote desktop(session ends), AutoIt script shows success but do nothing.

The "solution" was to keep virtual machine "open" by connecting it with TightVNC. Even closing the window, the VNC keeps the logon alive and AutoIt works without problems.

Hope this info helps you. Its not a solution but maybe you can workaround it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.