Typical Event Handler Scenario

In this scenario, Suzy is developing a script. Every now and then, a message pops up asking her to sign up for weekly tips. The message appears at unexpected intervals while performing the business process steps.

Suzy decides to create an Event Handler that closes this message whenever it appears. Here are the steps she follows to create the event handler:

  1. Suzy opens the Event Handler Editor from the main toolbar and clicks the button to add a new Event Handler.

  2. Because the message can pop up at any time, in the General section, Suzy selects Event can be triggered during the entire script.

    The handler is an “Object” type because the message appears within a regular DOM object and not within a browser dialog box.

  3. Suzy then clicks Click to choose an object and highlights the “SIGN ME UP!” button.

    After she chooses the object, TruClient creates identification for it:

    http://community.hpe.com/t5/image/serverpage/image-id/69333i6E604CA6958C9F84/image-size/original?v=mpbl-1&px=-1

  4. Suzy sets the Event Type to “Object Exists” so the event handler will be called each time the message pops up.

Now that the event is defined, Suzy creates a function that ignores the prompt and closes the message. To create the function:

  1. She closes the Event Handler Editor and, if the message is not displayed, she browses the application until it pops up.

  2. She starts recording and closes the message:

  3. She then stops the recording. TruClient recorded a navigation step and the close step. Suzy is only interested in the close step.

    http://community.hpe.com/t5/image/serverpage/image-id/69335iADDEC9A3EF368B1F/image-size/original?v=mpbl-1&px=-1

  4. To create the function from the close step, she selects the step, right clicks to open the context menu, and selects Group Into > New Function.


  5. When the Create new function dialog box appears, she enters a function name and a library name and clears the Replace steps with function call option so the script itself does not call this function. She wants only her event handler to call the function.

Now Suzy has a new function that contains a single step that closes the message.
The new function is listed in Function Libraries.

http://community.hpe.com/t5/image/serverpage/image-id/69338i9620E447673470D7/image-size/original?v=mpbl-1&px=-1


Now that Suzy has the function she needs, she opens the Event Handler Editor again and chooses CloseSignUp as the handler function.

http://community.hpe.com/t5/image/serverpage/image-id/69339iF3E193662B769AAB/image-size/original?v=mpbl-1&px=-1

Now she can record the business process as usual.

When she encounters the popup message during recording, she stops the recording and deletes the steps associated with it, since the event handler will close the message whenever it pops up in replay.

Back to top