Book Image

Advanced UFT 12 for Test Engineers Cookbook

Book Image

Advanced UFT 12 for Test Engineers Cookbook

Overview of this book

Table of Contents (18 chapters)
Advanced UFT 12 for Test Engineers Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Building an event handler


One risk we must handle during run sessions is exceptions, as they can have a fatal impact on the robustness of our automated tests. UFT provides the recovery scenario as a built-in solution (refer to Chapter 6, Event and Exception Handling), but it is quite complex to implement and may hinder the performance of the test.

In this recipe, we will see how to implement a simple recovery mechanism that is integrated with the controller (described previously) and that utilizes the same design pattern used for the regular actions to implement recovery procedures.

Getting ready

Add an Environment variable to the test. Name it ERR_DEFAULT and set its value to StopRunSession. Add another Environment variable named ERR_9 and set its value to ClearError. Create a function library named cls.EventHandler.vbs in the Lib folder, as already described in the previous recipe.

How to do it...

The following code shows a sample procedure implemented as an Action. The StopRunSession class...