Event handlers
This section describes TruClient event handlers, and how to use them to manage unexpected or unpredicted events that can occur during script replay.
Event handler overview
You use event handlers to help your test recover smoothly from behavior of the application that either:
-
Does not occur in every run. For example, during login, the user sometimes gets a notification: “Server is busy. Please wait for 10 seconds and try again”.
-
Occurs at unpredictable times. For example, the application displays a survey popup at random times.
If you record or add a step to handle such behavior, your script may fail when the behavior does not occur. If there is no step to handle it, the script may fail when the behavior does occur. An event handler calls a function to handle a condition only if the condition occurs.
You can create an event handler for these events:
-
Object event. Used when an object-related event occurs. For example, a certain object appears on the page, or a certain object property gets a certain value.
-
Dialog event. Used when a dialog box pops up. For example, an alert or a prompt.
Create an event handler
You use the Event handler editor to define event handlers.
To create an event handler:
- Click the Event handler editor button in the Toolbar.
-
Click the add button in the editor to add a new event handler.
An error icon is displayed next to the handler name until enough information is added to define the handler.
-
Enter the properties for the event handler. For details, see Event handler editor .
If a function that handles this event does not exist, close the Event handler editor and create the function. For details, see TruClient functions and function libraries.
After creating the function, reopen the editor and select the library and the function.
Event handler editor
The Event handler editor dialog box enables you to define events handlers and their properties.
UI Element | Description |
---|---|
<Event handlers panel> |
Add Event Handler. Add an event to the event handler. Delete Event Handler. Delete an event from the event handler. |
General |
|
Object |
Choose an object. Select the object from your application that will trigger the event handler. After you select an object, the following options are displayed:
|
Handler |
The handler function must be in a library.
|
See also: