Search here for all the info you want in this Blog

Recovery Scenario Manager(OR)Exception Handling

Using Recovery scenario manager, we can handle the exceptions (unexpected errors) in the QTP script.
Using the Recovery Scenario Manager dialog box, you can then select any recovery file to manage all of the recovery scenarios stored in that file. This enables you to edit a selected recovery scenario, associate specific recovery scenarios with specific tests or components to instruct QuickTest to implement the recovery scenarios when specified trigger events occur, and so forth. 
The following are the possible exceptions that can occur in the QTP script:
1.Pop-Up
2.Test Run Error
3.Application crash
4.Object State\Object Event

Pop-Up Exception: During the execution of the script some dialog box pop-up suddenly occurs which interrupts the execution of the script
Steps to handle Pop-up exception:
1.Ensure that the pop-up window is available
2.Select Resources --> Recovery Scenario Manager
3.Click on New Scenario(Image)--> Click on Next
4.Select the radio button ‘Pop-Up Window’ --> Click on Next
5.Click on the Hand icon
6.Click on the required pop-up window (captures the title & the message)
7.Implement the Regular Expression if required --> Click on Next
8.Select the Recovery operations ‘Keyboard or mouse operation’ --> Click on Next
9.Select the radio button ‘Click button with the label’ & click on the required button with the label --> Click on Next
10.Uncheck the check button ‘Add another recovery operation’--> Click on Next
11.Select the post recovery operation as ‘Repeat the current step & continue’ or ‘Proceed to next step’ (or as per the requirement)--> Click on Next
12.Provide the name & description --> Click on Next
13.Enable the check box ‘Add scenario to current test settings’ 
14.Click on Finish
15.Save the Recovery file. 
Note: The recovery file will be saved as .qrs (QuickTest Recovery Scenario)

Steps to associate the recovery scenario file to the QTP script:
1.Select File --> Settings
2.Click on Recovery Tab --> Click on Add (+)
3.Select the required Recovery file
4.Click on ‘Add Scenario’ button
5.Click on Apply & OK

Script to associate the recovery scenario file to the QTP script:
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Test.Settings.Recovery.Enabled = True
App.Test.Settings.Recovery.SetActivationMode "OnError"
App.Test.Settings.Recovery.Add "D:\Practise\QTP Testing\popupRS.qrs", "popupRS", 1
App.Test.Settings.Recovery.Item(1).Enabled = True

Steps to handle Pop-up exception by calling a Function:
1.Create an empty library file or use an existing library file
2.Select Resources --> Recovery Scenario Manager
3.Click on New Scenario --> Click on Next
4.Select the radio button ‘Pop-Up Window’ --> Click on Next
5.Click on the Hand icon
6.Click on the required pop-up window (captures the title & the message)
7.Implement the Regular Expression if required --> Click on Next
8.Select the recovery operation ‘Function Call’ radio button --> Click on Next
9.Select the required library file & define the required function --> Click on Next
10.Select the post recovery operation as ‘Repeat the current step & continue’ or ‘Proceed to next step’ --> Click on Next
11.Provide the name & description --> Click on Next
12.Enable the check box ‘Add scenario to current test settings’ 
13.Click on Finish --> Save the Recovery file.


Test Run Error: 
During the execution of the script, QTP throws an error if an object is not found (or) object description match more than one object (or) object not visible (or) item in the list or menu are not found (or) item in the list or menu are not unique, etc.
Steps to handle test run error:
1.Select Resources --> Recovery Scenario Manager
2.Click on New Scenario --> Click on Next
3.Select the trigger event as ‘Test run error’ --> Click on Next
4.Select the error message from the drop-down (if the exact message is not available, select any error) --> Click on Next
5.Select the recovery operation as “Function Call” --> Click on Next
6.Provide the library file path
7.Define the required function definition --> Click on Next
8.Select the post recovery operation as “Proceed to next step” --> Click on Next
9.Provide the name & description
10.Click on Finish --> Save the recovery file

Application Crash:
During the execution of the script, the application (AUT) crashes will interrupt the execution of the script.
Steps to handle Application Error:
1.Select Resources --> Recovery Scenario Manager
2.Click on New Scenario --> Click on Next
3.Select the trigger event as “Application Crash” --> Click on Next
4.Select the application from the “Running Process” list
5.Click on Add button (Then that application will be displayed in ‘Processes’ list --> Click on Next
6.Select the recovery operation as “Function Call” --> Click on Next
7.Provide the library file path
8.Define the required function definition --> Click on Next
9.Select the post recovery operation as “Proceed to next step” --> Click on Next
10.Provide the name & description
11.Click on Finish --> Save the recovery file

Object State\ Object Event:
The property value of an object in an application match with specific values can be specified at the object hierarchy.
Steps to handle Application Error:
1. Select Resources --> Recovery Scenario Manager
2. Click on New Scenario --> Click on Next
3. Select the trigger event as “Object State” --> Click on Next
4. Click on the hand icon & select the required object --> Click on Next
5. Click on ‘/Remove’ button to add or remove properties
6. Provide the expected values of the properties (Implement the Regular Expression if required) --> Click on Next
7. Select the recovery operation as “Function Call” --> Click on Next
8. Provide the library file path
9. Define the required function definition --> Click on Next
10. Select the post recovery operation as “Proceed to next step” --> Click on Next
11. Provide the name & description
12. Click on Finish --> Save the recovery file
On Error Resume Next: This option is used to proceed from the next line, when error occurs during the execution on the script without any interruption.
Eg: On error Resume next
- - - - - - - - - -
- - - - - - - - - -
Msgbox Err.number & Space(2) & Err.description & Space(2) & Err.Source
- - - - - - - - - -
- - - - - - - - - -
On Error go to 0
On Error Go to 0: It will turn off On Error Resume Next

No comments:

Post a Comment