If your test case requires you to validate the text of a modal dialog, you can use the AutoIT function WinGetText.

However, this method only works for IE modal popups. When using Firefox, the WinGetText function will output a nil. One possible solution around this is to highlight the text, copy it, send it to notepad, and then read it from there.

#Focus on your main window and then initiate the modal dialog pop-up

#Center the mouse over the text you want to grab and right mouse click

#Send the required key strokes to “Select All” and then copy (Ctrl + C)

#Open up notepad

#Activate and then wait for the notepad window to be active

#Paste the copied text into notepad

#Grab the notepad text and save it to a variable and then output the dialog text

#Close Notepad without saving

A quick video of the script detailed above:

The Modal Dialog shown in the video can be found at: http://www.phpguru.org/static/Modal-Dialog.html

Enhanced by Zemanta