QTP recovery scenarios provide a method for scripts to recover from different types of runtime error conditions. This is required for an unattended test case execution.
When not to use recovery scenarios?
Consider the following code, which has the potential to generate a divide by zero error exception:
‘Sample code with error probability
Y = z – 2
Y= 4 / y
We can handle this class or error using the On Error statement:
‘Handling predictable errors
Z = 2
Y = z – 2
On Error Resume Next
X = 4 / y
If Err.Number = 11 then
MsgBox “Error code divide by zero handled”
Else
‘Unknow error. Handler for unknown errors.
Msgbox err.Description & “ , “& err.source
End If
The above scenario produces a predicted specific error in a specific location in the code. This type of situation can only be handled using the “On Error Resume Next” statement, rather than a recovery scenario.
When to use recovery scenario?
We can use a recovery scenario when we know what type of error can occur, but don’t know when or where it might occur.
A recovery scenario consists of following components:
A Trigger Event: It is event that unexpectedly interrupts script execution. This event can be any one of the following:
Pop-up window
Object State
Test run error
Application Crash
A Recovery Action: This specifies what action needs to be taken after the associated trigger event has occurred and it can be any one of the following:
Keyboard or mouse operation
Close Application process
Function Call
Restart Microsoft Windows
Post Recovery Action: This specified what should be done once the recovery action has been successfully completed and this can be any one of the following:
Repeat current steps and continue
Proceed to next step
Proceed to next action iteration
Proceed to next test iteration
Restart current test run
Stop the test run
Navigation for applying RSM;
Resource menu -> Recovery Scenario Manager -> Click on New Scenario -> Click on Next button in wizard -> Select Trigger Event and identify corresponding object -> Click on Next button -> Select Recovery Operation -> Click on Next button -> Click on Next button ->Enter Name and Description -> Click on Next button -> Click on Finish button -> Save the created with .qrs extention.
Associating Created RSM
File -> Settings -> Recovery tab -> Click on ‘+’ button and browse the corresponding recovery file -> Click on Add Scenario button -> Click Apply button -> Click OK button.
Disassociating RSM:
File -> Settings -> Recovery tab -> Select associated fie -> Click on ‘X’ button -> Click Apply button -> Click OK button.
Contributed by: Vamshi Goutham
When not to use recovery scenarios?
Consider the following code, which has the potential to generate a divide by zero error exception:
‘Sample code with error probability
Y = z – 2
Y= 4 / y
We can handle this class or error using the On Error statement:
‘Handling predictable errors
Z = 2
Y = z – 2
On Error Resume Next
X = 4 / y
If Err.Number = 11 then
MsgBox “Error code divide by zero handled”
Else
‘Unknow error. Handler for unknown errors.
Msgbox err.Description & “ , “& err.source
End If
The above scenario produces a predicted specific error in a specific location in the code. This type of situation can only be handled using the “On Error Resume Next” statement, rather than a recovery scenario.
When to use recovery scenario?
We can use a recovery scenario when we know what type of error can occur, but don’t know when or where it might occur.
A recovery scenario consists of following components:
A Trigger Event: It is event that unexpectedly interrupts script execution. This event can be any one of the following:
Pop-up window
Object State
Test run error
Application Crash
A Recovery Action: This specifies what action needs to be taken after the associated trigger event has occurred and it can be any one of the following:
Keyboard or mouse operation
Close Application process
Function Call
Restart Microsoft Windows
Post Recovery Action: This specified what should be done once the recovery action has been successfully completed and this can be any one of the following:
Repeat current steps and continue
Proceed to next step
Proceed to next action iteration
Proceed to next test iteration
Restart current test run
Stop the test run
Navigation for applying RSM;
Resource menu -> Recovery Scenario Manager -> Click on New Scenario -> Click on Next button in wizard -> Select Trigger Event and identify corresponding object -> Click on Next button -> Select Recovery Operation -> Click on Next button -> Click on Next button ->Enter Name and Description -> Click on Next button -> Click on Finish button -> Save the created with .qrs extention.
Associating Created RSM
File -> Settings -> Recovery tab -> Click on ‘+’ button and browse the corresponding recovery file -> Click on Add Scenario button -> Click Apply button -> Click OK button.
Disassociating RSM:
File -> Settings -> Recovery tab -> Select associated fie -> Click on ‘X’ button -> Click Apply button -> Click OK button.
Contributed by: Vamshi Goutham