This section describes events 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 logon, 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.
How to create an event handler
To create an event handler:
- Click the Event Handler Editor button in the main toolbar.
Click the 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 of the event handler.
If a function that handles this event does not exist, close the Event Handler Editor and create the function. See TruClient functions and function libraries. After creating the function, reopen the editor and select the library and the function.
This dialog box enables you to define events handlers and their properties.
|Event Handlers Pane||
Add Event Handler. Add an event to the event handler.
Delete Event Handler. Delete an event from the event handler.
Type. You can select either Object or Dialog.
(Displayed only if you select Type= Object)
Click to 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:
Type: For an Object Event, select one of the following:
For a Dialog Event, the event is Dialog opened. When the specified dialog box is opened, the event handler is triggered.
The handler function must be in a library.