When doing automated testing, it’s common to run into a basic authentication window before you can access the application. WATIR can’t handle these authentication windows very well because it’s basically a modal popup with no associated DOM. That’s where AutoIT can be used to handle these authentication windows.
You can use AutoIT to send basic keystrokes to the active window, however, this will not work if the machine you’re running your automated tests on is locked. Instead of using basic Sends, you will have to use ControlSends to send text to certain windows on a locked machine. Luckily, AutoIT has a built in Window Info Screen that you can use to find the control of certain elements.
Drag the “Finder Tool” crosshair to whatever element (text field, button, etc.) you’re working with.
Once the Finder Tool selects the element, access the Control Tab in the Window Info page and you can see that the text field can be identified by the control [CLASS:Edit; INSTANCE:2].
To use this control to send keystrokes, use the ControlSend function so your code might look something like this:
ControlSend(“Connect to”, “”, “[CLASS:Edit; INSTANCE:2]”,”Send this text”)
Using the same procedure, you can fill in the user name and password and click OK to fully automate your test case.