All about Recovery Scenarios using QTP
While executing scripts, we usually encounter unexpected & unpredictable events & errors, which results into application crashing during a run session causing total disruption of the run session and distortion of results. Such problems are quite frequent especially when the tests are made to run unattended. In such a case the test process halts until the user perform some desired recovery operation.
Recovery scenarios are useful when it is difficult to predict at which step the errors can come or when we are confident that the error will not come in the QTP script, whereas it can be anywhere outside the QTP Script. For illustration; Pop-up message of “out of paper”, as caused by the printer device driver. “On error resume next” is preferred when we sure that the error is expected one and wish to perform some other actions.
In order to handle such situations QTP comes to our rescue by creating recovery scenarios and associates them with the particular tests. What does a Recovery Scenarios do is to activate a specific recovery operation when a trigger events takes place. Most simple example of a typical unexpected & unpredictable events & errors is like Incompatible Media in portable Drive.
The Recovery Scenario Manager presents a structured wizard which helps us in defining the recovery scenario, like detailed definition of the unexpected event and the operations required to recover from the exception during the run session.
Advantages of Recovery Scenario Manager: Recovery Scenario Manager can be used to handle several known errors occurring at runtime. Following four events available in the recovery scenario manager are extremely helpful
1) Application Crash: This event is useful in handling crashed applications at runtime.
2) Pop Up Window: This event is useful in managing various unwanted application windows, which get built-up at runtime.
3) Test Run Error: This event is useful in handling VBScript statement errors at runtime.
4) Object State: This event is useful in handling object related errors at runtime.
Elements of Recovery Scenario: Steps to handle the exceptions are
1) Trigger Event: Is an unexpected event like appearance of a Pop-up window, object state, test run error causing application crash or interruption in our running session.
2) Recovery Steps: Constitutes a series of steps required to be performed to enable QTP to proceed further with the process of test after some trigger event has interrupted the run session. Examples of a recovery operation can be 1) A keyboard or mouse Operation like a Click over the “OK” button in the Pop-up window 2) Close Application Process 3) Function Call 4) Restarting the OS etc.
3) Post-Recovery Test Run: Are a set of instructions designed to be provided to QTP on proceeding further with the test after some recovery operation has been carried out. Examples of Post Recovery actions can be repeating the complete test from the beginning or some steps may be skipped altogether & continuing with the remaining steps in the test.
QTP & Recovery Scenarios:
All Recovery scenarios get saved & logically grouped in recovery scenario files. Grouping of various recovery scenarios in recovery scenario file can be managed according the user requirements. Recovery scenario files carry a typical extension of .rs.
In order to instruct QTP to carry out a recovery scenario during a particular test run, we firstly associate it with the particular test. There is no limitation to any fixed number of recovery scenarios associated with a test. Order of execution of various recovery scenarios associated with a test can easily be prioritized, thereby the trigger events get recognized and handled in the desired sequence.
Whenever any error comes during the execution of a test having many recovery scenarios associated with it; QTP intelligently hunts for the defined trigger event which had caused the particular error. After detecting the trigger event, QTP automatically performs the desired recovery steps and post-recovery test runs etc.
Recovery statements can be inserted in the tests to comfortably control and activate the recovery scenarios during the test run.
Cons of Recovery Scenarios:
Although Recovery Scenarios are users friendly on one hand; they tend to slow down the speed of the Test Run. Presence of a few such recovery scenarios would reduce the speed of Test Run significantly. This can become irritant to the testers, who can prefer the approach of using VBScript On Error/Goto 0 far more useful for catching & handling small errors.
Many More Articles on HP QuickTest Professional