Squish tip of the week: Handle unexpected events

Squish tip of the week: Handle unexpected events

Did you know that Squish can monitor for various events and dialogs? The events can be handled, allowing scripts to continue where they left off.

For example, in a Windows application you may install an event handler to react to unexpected open message boxes using MessageBoxOpened. The example below demonstrates logging the handled event and closing the message box should the message box appear at any point in the executing script:

def handleMessageBox(messageBox):
    test.log("MessageBox opened: '%s' - '%s'" % (
        messageBox.windowText, messageBox.text))
    messageBox.close()

def main():
    startApplication("myapp")
    installEventHandler("MessageBoxOpened",
                        "handleMessageBox")
    ...
Learn more about using event handlers