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.
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.