Modal dialogs are pop-ups that need attention before the user can go back to their testing window. Modal dialogs are difficult to automate using only Ruby and Watir because you can’t access the html source code of a modal dialog. Since AutoIT does not require any source code to operate, it is a viable tool to deal with modal dialogs.

Closing Pop-ups
One way to use AutoIT to close a modal dialog pop-up would be to activate the browser before the pops up appears and then send the required key strokes to close the pop-up.


#Initiate the modal dialog pop-up

#Send the ENTER key to close the modal dialog. However, it is best to avoid sending keystrokes because of possible timing issues. A better way to use AutoIT would be to use the WinClose function.

#WinClose requires the window’s handle or title. WinGetTitle will retrieve the title of the active window which in this case would be the modal dialog since it just popped up.

#The WinClose function should close the modal window.

Enhanced by Zemanta