installEventHandler

installEventHandler(eventName, handlerFunctionNameOrReference)

This function installs a global event handler. The script function named or referenced in handlerFunctionNameOrReference, will be called when an event of the eventName type occurs.

The eventName can be the name of any of the following event types:

  • Crash: This event occurs if the AUT crashes.
  • DialogOpened: This event occurs when a dialog window is opened; a "dialog window" is a window with the (extended) styles DS_MODALFRAME + WS_EX_DLGMODALFRAME + WS_EX_WINDOWEDGE + WS_EX_CONTROLPARENT or DS_SYSMODAL + DS_SETFOREGROUND + WS_EX_TOPMOST + WS_EX_WINDOWEDGE + WS_EX_CONTROLPARENT (styles can be checked with Microsoft's Spy++ tool from Visual Studio).
  • MessageBoxOpened: This event is occurs when Squish detects that a dialog window was opened (i.e., the same requirements as given in the explanation of the DialogOpened event apply), but the dialog window also matches a certain structure. The exact structure depends on the particular GUI toolkit but it usually means that the dialog should contain just text and some standard buttons like OK and Cancel.
  • Timeout: This event occurs when the Squish response timeout is reached.

The function named in handlerFunctionName is called with a single argument—the object on which the event occurred.

Note: In Python scripts, you can specify the callback function to invoke by passing an actual function or a lambda function.

For examples see How to Use Event Handlers.

Note: The installEventHandler function will only work if it is called after the AUT has been started. For example, by using the ApplicationContext startApplication(autName) function.

uninstallEventHandler(eventName, handlerFunctionNameOrReference)

This function uninstalls an event handler that has been previously installed using installEventHandler(eventName, handlerFunctionNameOrReference).

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results