QTP Recovery Scenario |
QuickTest Professional Recovery Scenarios are summarized in the below mentioned points with 3 "easy to understand" examples.
1)
With "Recovery Scenario Manager" you can
a) create and edit recovery files,
b) create and manage the recovery scenarios stored in those files.
2)
A unique icon corresponds to a recovery scenario that indicates its type.
3)
Each recovery scenario is represented by an icon that indicates its type.
4)
You are guided step-by-step, through the process of creating a recovery scenario by Recovery Scenario Wizard.
5)
You start by defining the trigger event. [4 trigger types are there Pop-up window, Object state, Test run error, Application crash]
6)
After that you specify the recovery operation(s) [Recovery Operation can be Keyboard or mouse operation, Close application process, Function call, Restart Microsoft Windows]
When using Function call, Functions have to be defined using a prototype syntax, which is different for each trigger type.(See QTP User Guide.)
7)
Then you select a post-recovery test run operation. [Which can be Repeat current step and continue, Proceed to next step, Proceed to next action or component iteration, Proceed to next test iteration, Restart current test run, Stop the test run]
8)
The recovery file is saved in the specific location with the file extension .qrs.
9)
Properties for any defined recovery scenario can be viewed from Recovery Scenario Properties dialog box
10)
During the run session, QuickTest ignores deleted recovery scenario that is associated with a test or component.
11)
You can copy recovery scenarios from one recovery scenario file to another.
12)
The scenarios can be prioritized so that QuickTest applies the scenarios during the run session in a order of priority.
13)
Some or all of the scenarios can be disabled.
14)
Recovery Scenario(s) can be set as default for all new tests.
15)
Go to File > Settings, the Test Settings dialog box opens. Select the Recovery tab.
You can edit a recovery scenario file path by clicking the path once to highlight it, and then clicking it again to enter edit mode.
16)
In the Recovery tab itself you can define when the recovery mechanism is activated:
On every step.
On error
Never.
17)
You can use the Recovery object to control the recovery mechanism programmatically during the run session.
With "Recovery Scenario Manager" you can
a) create and edit recovery files,
b) create and manage the recovery scenarios stored in those files.
2)
A unique icon corresponds to a recovery scenario that indicates its type.
3)
Each recovery scenario is represented by an icon that indicates its type.
4)
You are guided step-by-step, through the process of creating a recovery scenario by Recovery Scenario Wizard.
5)
You start by defining the trigger event. [4 trigger types are there Pop-up window, Object state, Test run error, Application crash]
6)
After that you specify the recovery operation(s) [Recovery Operation can be Keyboard or mouse operation, Close application process, Function call, Restart Microsoft Windows]
When using Function call, Functions have to be defined using a prototype syntax, which is different for each trigger type.(See QTP User Guide.)
7)
Then you select a post-recovery test run operation. [Which can be Repeat current step and continue, Proceed to next step, Proceed to next action or component iteration, Proceed to next test iteration, Restart current test run, Stop the test run]
8)
The recovery file is saved in the specific location with the file extension .qrs.
9)
Properties for any defined recovery scenario can be viewed from Recovery Scenario Properties dialog box
10)
During the run session, QuickTest ignores deleted recovery scenario that is associated with a test or component.
11)
You can copy recovery scenarios from one recovery scenario file to another.
12)
The scenarios can be prioritized so that QuickTest applies the scenarios during the run session in a order of priority.
13)
Some or all of the scenarios can be disabled.
14)
Recovery Scenario(s) can be set as default for all new tests.
15)
Go to File > Settings, the Test Settings dialog box opens. Select the Recovery tab.
You can edit a recovery scenario file path by clicking the path once to highlight it, and then clicking it again to enter edit mode.
16)
In the Recovery tab itself you can define when the recovery mechanism is activated:
On every step.
On error
Never.
17)
You can use the Recovery object to control the recovery mechanism programmatically during the run session.
On Error Statement |
On Error statement enables or disables error handling.
Two On Error statements which we will discuss here are:
On Error Resume Next
On Error GoTo 0
If there is an error in the code "On Error Resume Next" ignores it and continues with the next line of the code.
Consider the below example. Write the below code in a notepad and save it as a .vbs file and run it from the command prompt. It works fine, but now if you comment or remove the "On Error Resume Next" line, it will show error because of the 7th line.
msgbox "Ha Ha 1"
call one
msgbox "Ha Ha 2"
Function one()
call one
msgbox "Ha Ha 2"
Function one()
On Error Resume NextEnd Function
msgbox "Function one Start"
two
msgbox "Function one End"
msgbox "Ha Ha 3"
msgbox "Ha Ha 1"
call one
msgbox "Ha Ha 2"
call two
call one
msgbox "Ha Ha 2"
call two
Function one()
On Error Resume NextEnd Function
msgbox "Function one Start"
happy
msgbox "Function one End"
Function two()
On Error Resume NextEnd Function
msgbox "Function two Start"
happy
msgbox "Function two End"
msgbox "Ha Ha 3"
Run the above program, it will show the last message box "Ha Ha 3", but if you comment the "On Error Resume Next" of Function two() then you will not see the last message box "Ha Ha 3" because when the program finds the word "happy" in Function two() and no error handler, it raises a Type Mismatch error.
Note that with "On Error Resume Next" error is not corrected, just ignored, and an error message is not displayed.
Use On Error GoTo 0 to disable error handling if you have previously enabled it using On Error Resume Next.
Whenever there is a run-time error in the program, the properties of an Err object are filled with the information that helps to identify and handle the error.
After an On Error Resume Next statement the Err object's properties are reset to zero or zero-length strings ("").
Because the Err object is an intrinsic (basic / its part of every vbscript project you create) object with global scope — there is no need to create an instance of it in your code. That is it does not need to be declared before it can be used.
| Properties | Purpose |
|---|---|
| Description | Contains a string describing the error. |
| Number | Contains the Error number. It is the default Property, means Err.Number is same as Err |
| HelpFile | Contains path to the help file |
| HelpContext | Its a Context ID within the helpfile. The HelpContext property is used to automatically display the Help topic identified |
| Source | Contains a string expression that is usually the class name or programmatic ID of the object that caused the error. |
| LastDLLError | Contains last error code generated by DLL;Available only on 32 bit windows systems. |
| Methods | Purpose |
| Clear | Clears all property settings of the Err object. [VBScript calls the Clear method automatically whenever any of the following statements is executed:On Error Resume Next |
| Raise | Forces a run-time error of a given number to be generated. |
msgbox "Ha Ha 1"
call one
msgbox "Ha Ha 2"
Function one()
call one
msgbox "Ha Ha 2"
Function one()
msgbox "Function one Start"End Function
happy
msgbox "Function one End"
Firstly, try to run the above code, when the program reaches the line which has 'happy', it will show Type Mismatch error.
Now run the below code which now has "On Error Resume Next" and Err object. This is just one of the million ways you can use Err object. You can also use Err number in conditional statements and loops etc to make the code more robust.
msgbox "Ha Ha 1"
call one
msgbox "Ha Ha 2"
call one
msgbox "Ha Ha 2"
Function one()
On Error Resume NextEnd Function
msgbox "Function one Start"
happy
msgbox "Error number is = " & err.number & " and " & "Error Description = " & err.description
msgbox "Function one End"
No comments:
Post a Comment