What are Recovery Scenarios?
While executing your scripts you may get some UNEXPECTED/UNPREDICTABLE errors. (like printer out of paper). To “recover” the test (and continue running) from these unexpected errors you use Recovery Scenarios.
Next question arises,
When to use “on error resume next” or programmatic handling of errors VS Recovery Scenarios ?
If you can predict that a certain event may happen at a specific point in your test or component, it is recommended to handle that event directly within your test or component by adding steps such as If statements or optional steps or “on error resume next”, rather than depending on a recovery scenario. Using Recovery Scenarios may result in unusually slow performance of your tests.They are designed to handle a more generic set of unpredictable events which CANNOT be handled programmatically.
For Example:
A recovery scenario can handle a printer error by clicking the default button in the Printer Error message box.
You cannot handle this error directly in your test or component, since you cannot know at what point the network will return the printer error. You could try to handle this event in your test or component by adding an If statement immediately after the step that sent a file to the printer, but if the network takes time to return the printer error, your test or component may have progressed several steps before the error is displayed. Therefore, for this type of event, only a recovery scenario can handle it.
I would not go into details of how to create files and how to define them since they are fully covered in QTP Documentation. Mercury QuickTest Professional User’s Guide > Working with Advanced Testing Features > Defining and Using Recovery Scenarios >
What constitute Recovery Scenarios?
A recovery scenario consists of the following:
- Trigger Event. The event that interrupts your run session. For example, a window that may pop up on screen, or a QTP run error.
- Recovery Operations. The operations to perform to enable QTP to continue running the test after the trigger event interrupts the run session. For example, clicking an OK button in a pop-up window, or restarting Microsoft Windows.
- Post-Recovery Test Run Option. The instructions on how QTP should proceed after the recovery operations have been performed, and from which point in the test QTP should continue, if at all. For example, you may want to restart a test from the beginning, or skip a step entirely and continue with the next step in the test.
Recovery scenarios are saved in recovery scenario files having the extension .rs. A recovery scenario file is a logical collection of recovery scenarios, grouped according to your own specific requirements.
Is there a method to programmatically call them?
By default, QTP checks for recovery triggers when an error is returned during the run session. You can use the Recovery object’s method to force QTP to check for triggers after a specific step in the run session.
For a complete list go to QTP Documentation > Quick Test Advanced References > Quick Test Automation > Recovery Object
If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.
Hi,
My goal is to set a recovery scenario such that on error, I want the QTP to retry executing the statement once and if the statement fails again, then proceed executing the next step. Is there a way to achieve this?
Hi Ankur,
I am new to learning QTP and have learnt basics of QTP. My question is: How we can write recovery scenario to close web application.
For example: If I have a webpage opened with URL: Now, while running the scripts in QTP it is invoking the same webpage for execution. In this scenario 2 instances of same webpage will be opened and it will become hard for QTP to recognize the correct object on webpage/.
So how can we write recovery scenario for such case?
hi,
In that Case instead of Writing Recovery Scenario YOu can utilize Property called “Creation time” which is available in Object Repository.
According to QTP, Webpage opened for first time creation time will be 0. So, if its opened again then Creation Time will be 1.
In Your Code you can mention.
If Browser("xx").Page("xx").GetRoProperty("CreationTime") >0 Then
Browser("xx").Page("xx").Terminate()
End If
Thanks,
Pravallika
if ur pop window is not removing after applying recovery then just check that did u use invoke app at the start of script or check the synchronization time from setting.may be the time limit is less
ankur..it is simple!first u have to find what error u r getting and also are u getting the error from application or qtp.like if qtp is throwing the error object is disable then the trigger event will be test run.and u are applying wrong value then u will get the error run error then trigger option will be pop up .i think it help u
Hi Ankur, the concept is very well understood. Can you please give me an example of application crash trigger event?
Hi Ankur,
I have a webpage where i have to enter employee details. Let us say i entered the employee name as “Babu”. Again i want to create one more employee. I mentioned the employee name as “Babu”.After commiting the operation, it is displaying the message that “Employee name is already exists”. I want to select Close button and select insert button to insert new employee details whenever the message window comes in between.
For that i had written popup window recovery scenario and i selected close button.
But when i try to execute the same script, created recovery scenario is not getting called and the pop up window is not getting closed.
Help me out for the above mentioned scenarios, how to add recovery scenarios.
Hi Ankur,
I am very new to QTP and trying to practice and learn as much as i can till a project comes my way. Thanks to you for giving so much of information specifically to new comers in this field. I would like to know about all the things in QTP and all its versions.I look forward to a positive and early response at your convenience. please provide me articles at arunadevi.sks@gmail.com
Thanks in advance,
Aruna.
I have dowloaded QTP handbook I am am trying to learn QTP, however unable to run the test. After I stop the recording RUN tab is not getting highlighted I cant click on it… what is wrong pls help…
Beena
Hi,
Can any one please suggest how and where to add the recovery scenario during sripting….
Hi Ankur,
I am new to QTP and trying to practice and learn as much as i can till a project comes my way. Thanks to you for giving so much of information specifically to new comers in this field. I would like to know about how to test map navigation and analysis program running on mobile devices. I look forward to a positive and early response at your convenience. Thanks in advance,
Shalini
Hi Ankur,
I am not getting how to create recovery scenario for application crash
please tell me how to do it,means which trigger event I have to choose ?
help me please
Hi,
Can someone please submit the code snippet demonstrating how to handle run error programatically.
Thanks
Hi Everybody,
I am new to QTP. Problem I am having is with recovery manager in 9.5.
I have tried using a scenario to close a popup window.But after adding the scenario to the test , the QTP is not closing the popup window.
Plase help.
Anirban
Hi anonymous,
I have used Error Recovery Scenario to handle those run Time Error Message Box that you will get when any object property is changed and error occur.
I have done it using vb script also.. like when ever that message pops up, I am just clicking “Retry” button 3 time and if 4th time if again it occur – I am skipping it clicking on Skip button.
@Viji,
I am able to open the page “step -by step guide to learn QTP”[http://mercuryquicktestprofessional.blogspot.com/2008/02/step-by-step-guide-to-learn-qtp.html] must be some problem from your end.
Hello Ankur,
This is viji , i work in london.I am in the process of creating automated test scripts using QTP 9.1 for one of teh websites i am testing.
i saw ur blog and its usefull but unable to download ‘Step by step guide to learn QTP for beginners’
please suggest a way to do that.
Thanks and Regards
viji JP
Does Recovery scenario handle the Run Error occurred due to OR property change or object not found or Application crash.
i have tried using one to close process option in Recovery scenario for closing all the browser’s and stopping test.
But after adding the scenario to the test also, the QTP 9.2 is not stopping the script and not also closing the browsers.
Can u provide ur comments on this. if its working for u, pls provide me some inputs so that i can also implement it.
Thanx
Sreedhar6363@gmail.com
mallipeddi_sreedhar@yahoo.com