Recovery Scenario Test Run Error: Item in list or menu not found

by Anshoo Arora ON October 19, 2009 · Posted In All, QTP · 98 comments

Automated tests are created mainly to be run unattended, and this raises a few concerns for automation developers. Assume a situation where you initiated your test-suite while leaving your office to be run over-night. However, because of unforeseen errors, your test stops at a point and disrupts your results. When you return to your desk the next day, only to find that your tests aren’t completely executed. This can be quite frustrating, and its crucial to be proactive and handle such errors before they impact your work.

This article discusses a way of creating a Recovery Scenario for an instance where an item in the list item or menu is not found.

In this example, we will define a Function Call and use that Function Call to handle the error. The default syntax for the Recovery Scenario Function is:

Function fnRecovery(Object, Method, Arguments, retVal)
        'Error Handling Code
End Function

Explanation of each argument to fnRecovery is given below:

Object as Object: The object of the current step.
Method as String: The method of the current step.
Arguments as Array: The actual method's arguments.
Result as Integer: The actual method's result.

To handle this scenario, we will use the function below:

Function Recovery_ListItemIsNotFound(Object, Method, Arguments, retVal)
     Dim sAllItems, arrAllItems, intItem
 
     With Object
          'Retrieve all items from the Listbox
          sAllItems = .GetROProperty("all items")
          'Split 'all items' using a delimiter ";" into an array
          arrAllItems = Split(sAllItems, ";")
 
          'Select a random number
          intItem = RandomNumber.Value(LBound(arrAllItems), UBound(arrAllItems))
          .Select "#" & intItem
 
          Reporter.ReportEvent micInfo, "ListItemIsNotFound", "Item: " & .GetROProperty("value")
     End With
End Function

Recovery_ListItemIsNotFound, as the same suggests, executes the Recovery Operation if the list item that we supplied to our target WebList does not exist. This is quite common in Web applications, and Items in a WebList can change depending upon the input(s) provided.

To start, Click Resources -> Recovery Scenario Manager. You should see a window like this:

Recovery Scenario Wizard

Recovery Scenario Wizard

In the window, click the following button:

Doing so will invoke the Recovery Scenario Wizard:

Recovery Scenario Wizard - Welcome

Recovery Scenario Wizard - Welcome

When the window above opens:

  1. Click Next
  2. Select Test Run Error as the Trigger Event

  3. Click Next
  4. Select ‘Test Run Error: Item in list or menu not found in the Error Listbox

  5. Click Next twice and navigate to Recovery Operation

  6. Select Function Call and Click Next

  7. Select a library which will store our Recovery Function.

  8. Select ‘Define New Function’ and in the TextArea, paste the function Recovery_ListItemIsNotFound

    Define New Function

    Define New Function

  9. Click Next
  10. Make sure ‘Add Another Recovery Scenario’ Checkbox is not selected and click Next again.

  11. Under Post-Recovery Test Run Options, select proceed to next step.

  12. Give your scenario a name and Click Next

  13. And finally, Check the following option: Add Scenario to current test and Click Finish. Save Changes before closing.

We will use the WebList below to select a value that does not exist in it; so, let’s write a code to select Rational Robot. If you view the items present in the listbox, you will notice that Rational Robot indeed doesn’t exist, but our Recovery Scenario will handle the error when we select it. Instead, it will select a random value from the list.

Browser("title:=.*Recovery Scenario.*").Page("micclass:=Page")_
    .WebList("name:=testTools").Select "Rational Robot"
 
MsgBox "Item Selected: " & Browser("title:=.*Recovery Scenario.*").Page("micclass:=Page")_
	.WebList("name:=testTools").GetROProperty("value")

When the code above executes, you will notice that, instead of throwing a Test Run Error, a random value from the list box was selected. You will know that the Recovery Scenario was triggered and ran successfully when you view the Test Results:

Recovery Scenario Executed

Recovery Scenario Executed

There are plenty of other scenarios as well, and I will try to cover some of the important ones. If you have any suggestions, or a scenario that you would like me to cover first, please use the comments section of this post to share your ideas/thoughts with me. Thanks! :)

Subscribe to Relevant Codes (by Anshoo Arora)

Hello! We're always posting interesting articles on Relevant Codes. Why not subscribe so you don't miss out?

Leave a Comment

{ 98 comments… read them below or add one }

Roselin May 17, 2012 at 12:00 pm

Hi,

I am getting an pop-up window while executing the test. Script has to close that window to proceed to next step.
Please help me with it.

Thanks in advance.

Reply

s singh April 25, 2012 at 6:44 am

Hi Anshoo,

Can u pls tell me how to create recovery scenario to stop QTP script execution when application on which we are running the script goes down.

Reply

Anshoo Arora May 2, 2012 at 2:03 pm

S Singh, the recovery scenario you design for this can just have ExitTest in it. If the RS runs, it will simply exit the test. If it goes down because of issues that you can control, I would recommend Conditional logic or On Error Resume Next instead.

Reply

s singh May 16, 2012 at 5:43 am

Hi Anshoo,

I am running QTP scipts in night without monitoring it. So whenever my application goes down, QTP continues running and gives wrong results. What I need now is that a recovery scenario be created for this so that whenever application goes down due to any reason (which is not under my control), QTP should get stopped.

Please suggest.

Reply

Piyush February 23, 2012 at 6:36 am

Hi Anshoo,
my problem is when I am calling recovery function in wizard which already exist in library,after selecting “select function” radio button I dont see any function in list from that function library(here I m not using “define new function” radio button).

Please suggest.

Reply

Anshoo Arora March 15, 2012 at 8:27 am

Piyush, you will see the function in the list if it meets the criteria for it to be a RS function – that is, it must have the required args. Example:

Function SomeFunc(Object)
    'code
End Function

Reply

Anonymous January 19, 2012 at 12:14 am

can you please give some more example for recovery scenario because i tried for pop up window and object state. . . so please give some simple example for objects present in the application. . .

Reply

Amit January 5, 2012 at 5:06 am

Hi Anshoo,
Code I have written for recovery scenario is as below:
Function Recovery_ObjectNotFound(Obj, Method, Arguments, retVal)
msgbox err.number
msgbox err.source
msgbox err.description

End Function
But when this function is executed then msgbox shows 0 for error number and blank for source and description. It means that err object is getting reset. As on next line in script also same values are shown

Reply

Amit January 5, 2012 at 12:15 am

Hi Anshoo,
I am new to QTP, some times i get Object not found test run error from QTP. In my script I have added some checks which skips rest of lines if any step fails, but if i get an error like this I would like to log it in my result array so that it will be present in my report excel. SO can you tell me how to capture those errors and their bodies? and also custom function which I have written to record my results can be called from recovery functions to log results in my result array?

Reply

Anshoo Arora January 12, 2012 at 11:46 am

Amit, a very good way to avoid “Object Not Found” is by using the .Exist method.

Reply

vijayalakshmi October 27, 2011 at 12:16 am

hi,i saw this example but am having one doubt ‘#” this one is used in script am not undestand this one….

Reply

Naveen Khunteta September 27, 2011 at 8:55 am

Dear Anshoo,
I have a problem with my framework. Hope u can give a appropriate solution regarding Recovery Scenrios.
–suppose I am going to execute 20 test cases through the driver script with the Execution_Flag=Y defined in Test Data sheet.
–for each scenario, I am maintaining a Environment Variable to capture the Scenrio_Name and Result like :

—–Environment.Value(“strResultparam”)=StrScenarioName1 & “|” & strResPassVal (If this case is passed)
—-Environment.Value(“strResultparam”)=StrScenarioName1 & “|” & strResFailVal (If case is failed)

at the end of 20th test case execution, the environment variables would be like:
>Environment.Value(“strResultparam”)=Environment.Value(“strResultparam”) & “##” & StrScenarioName1 & “|” & strResFailVal

–Like:::Environment.Value(“strResultparam”)=verifyLogin|Pass##verifyHomePage|Pass……………………VerifyAddUser|Fail…..and so on..

>>Now at the end of 20th test case execution, I am calling a “Fn_WriteResult” function in which I am passing this Env. variable as a parameter.
>>In This function, I have written a code which will seperate the Env. Variable on the basis of ## and will return an array like below:

Public Function fn_WriteResults1(byval strRes)
ArrTestData=Split(strTestData,”##”)

And after that, I am just entering the elements of this array into an excel sheet like below:
—————————————————————
ScenarioName Result
verifyLogin Pass
verifyHomePage Pass




VerifyAddUser Fail
—————————————————————

Now my problem is, in this approach: I am collecting values and concatenating the multiple values on the basis of test case scenarios and Pass/Fail result.
But Suppose, some of the sceanrio(suppose 5th scenario) is not able to execute just coz of Object not found error or any run time error. Hence I need to ignore that step and want to come to the next step so that, my env variable collection would not corrupt.

Please suggest any solutions, How can I avoide such run time errors. Can I use On error/Go to 0 for each scenarios?
or any other solution?

Once all the scenarios have been executed

Reply

Anshoo Arora September 29, 2011 at 9:38 pm

Naveen: depending on how you have created your framework (actions vs. function libraries) you can use a Class_Terminate() event to run after each actions completes. I am providing some sample code, but please modify it for your usage:

Class ActionTerminate
    Private Sub Class_Terminate()
        If Reporter.RunStatus = micFail Or Err.Number  0 Then
            Err.Clear

            Environment.Value("strResultparam")=StrScenarioName1 & "|" & strResFailVal
        Else
            Environment.Value("strResultparam")=StrScenarioName1 & "|" & strResPassVal
        End If
    End Sub
End Class

And yes, please use Error Handling where required: Conditional statements, On Error Resume Next, Recovery Scenarios etc.

Reply

Jayaprakash September 20, 2011 at 5:02 am

The way of explaining the “Recover operation-Function call” is good
Thank u

Reply

Dhana August 18, 2011 at 5:23 am

Hi Anshoo,,

In my office for eavry 18 mins the system will be automatically locked if it is ideal for that much time. Is there any QTP script to avoid that tipe of situation to run the Scripts continuosly please let me know.

Thanks in advance

Reply

Anshoo Arora September 12, 2011 at 10:14 pm

Dhana: Please see here

Reply

Dhana August 18, 2011 at 5:13 am

Hi Friends,

I want QTP scripts for following scenario:

When we are executing QTP scripts some times it will fails at that time i want to take a screenshot of runtime error and need to be stored it some spceific folder and then i want to kill my application and need to reopen it.

Can anybody help me to solve this issue.

Thanks in advance.

Reply

Anshoo Arora September 12, 2011 at 10:01 pm

Dhana: There are several ways you can achieve this and there is a technique I love a lot, which is from Tarun’s book – which I can’t share with you at this point of time. We must wait until it is officially published. In the meantime, you can try the following:

Public Sub OnEventFail(ByVal capturePath, ByVal terminateApp)
    If capturePath <> "" Then
        Desktop.CaptureBitmap capturePath, True
    End If

    If terminateApp Then
        'depending on type of app, execute terminate procedure
    End If
End Sub

Reply

Shivaraju C M August 8, 2011 at 6:09 am

Hi Anshoo,

Thanks for this valuable post. I have written a recovery scenario function to capture the screenshot on error. But I am getting The function is not found error at run time.
It will be great if you provide the solution to my problem. The function is as below.

Function RecoveryFunction1(Object, Method, Arguments, retVal)
Desktop.CaptureBitmap(“c:\Error.png”, 1)
End Function
Waiting for your replay.

Thanks & Regards
Shivu

Reply

Anshoo Arora August 16, 2011 at 8:51 pm

Shivraju: Is the function stored in a library? If yes, then is the library associated with your test?

Reply

Rati July 20, 2011 at 3:01 am

how can i create Recovery Scenario for Application Crash.When running the script IE crashes sometimes.How can i handle this with Recovery scenario.

Please help me

Reply

vikram June 29, 2011 at 6:23 am

How do we pass values between actions in one test other than by action call?
Say for eg, if action_1 contains a variable ‘C’ containing the value of a+b, how can we display the result (value of ‘C’) in action_2 ?

Reply

Anshoo Arora June 29, 2011 at 7:18 pm

Vikram: You can either create a the variable C as a global variable, or an Environment variable. Either way, you will be able to see the value it stores in any of the actions.

Reply

vikram June 29, 2011 at 6:20 am

I have one doubt that ” When to user Update Run mode”

Reply

vikram June 29, 2011 at 6:22 am

reply the answer to my mail vyedavelli@gmail.com

and also why it is needed

Reply

Chandra June 15, 2011 at 7:06 am

Hi in the above ListItemnotfound recovery, the object properties are accessed using .getropropery(). But when i was using the same for AnyError, i am getting “General error”. Can any one let me know how to access the “Object,Method,Arguments and retval” with examples.

My requirement is to display message (like object name, method name, arguments and retval) in the recovery scenario function for “AnyError”.

So when QTP encounters any error, it will invoke the recovery scenario which inturn the function and then it displays the message in the message box with details like object name, method name, arguments and retval. The user will click on ok button and the post recovery operation will be invoked bye the recovery scenario.

Reply

Deep April 11, 2011 at 2:13 am

Hi Anshoo,

Your style of explaining the things is very good even a novice user can understand.
i have one question for you, if i have 10 recovery files, how do i make sure that based on that particular instance i call the particular recover file.

for example:

1.recoveryfile1
2.recoveryfile2
….
recoveryfilen

error message which requires recoveryfile2 to handle
error message which requires recoveryfilen to handle

is there any mechanism to handle this?

Reply

Sai June 14, 2011 at 6:29 am

Hi Deep,
How many ever recovery scenario files you created, you just need to add all of them to the required test. As per the scenario demands, i.e, when there is any unexpected exception, automatically QTP checks for an appropriate recovery scenario out of the one’s attached to the test. This is the actual thing expected out of a recovery scenario.
To my knowledge, there is no specific mechanism defined to handle this.
Please correct me if I am wrong in any sense.
Thanks :-)

Reply

Anonymous February 12, 2011 at 7:11 am

Thanks!very useful

Reply

NewToQTP December 17, 2010 at 1:06 pm

Hi,

I would like to create a recovery scenario for a Pop-up window that might appear when I click any button on my web app.
However, since I do not want to enable this recovery scenario for after every step beacuse of performace slow down issues. Is there a way to enable it only after any step that clicks on a button/image?

Reply

Suresh Kumar Jakka November 1, 2010 at 2:08 am

1) How to write a script for recovery scenario through descriptive programme.
For example
1) A pop-up Internet explorer has open after login to the account.
This is the script
Browser(“Google”).Window(“Internet Explorer”).Page(“Internet Explorer”).WebButton(“OK”).Click
3) I have written it in descriptive programme.
4) But QTP Tool is not recognize it for a long being time.

OR
Given me one example how to write Recovery scenario using scripting.

Reply

Venkat October 30, 2010 at 1:34 pm

Hi Anshu,

One doubt about the way QTP treats the application when a recovery scenario is triggered.Does the recovery scenarios follow strict rules when the post recovery options are applied on them.

Problem in detail:

– Action1 (Encountered error – Recovery Scenario triggered)
Step1
Step2
– Action2

When I choose post recovery operation as ‘Skip to next Action’.
Does it work properly or QTP tries to execute the steps after the Action1 (where recovery scenario is executed)

Reply

Anshoo Arora November 14, 2010 at 5:24 pm

Venkat,

When the action is complete and the RS enters the Post-Recovery phase, it will automatically implement Action2 and stop execution of Action1 from the point where it was triggered.

Reply

Ash August 20, 2010 at 8:04 am

Hi,

I am using the QTP Trial version, where i has install and UnInstall the software after unstalled the software.
Now the Record and Playback functionality of QTP is not working properly whenever i do to record and playback any web or window application; blank script is running. let me know it ‘s happing.
Thanks :)

Reply

Alvin August 19, 2010 at 12:37 pm

Hi,
Very informative and detailed way of explaining the scenarios. Appreciate the way you presented it. Here in the example, WebList object is static and present always on page. So, we can use Test Run Error and call a function. My scenario is different. When I access any website, security dialog pop-up (WebSense) comes up and I need to enter my Username and Password and click OK. This Websense may pop-up anytime(no specific time) after that as long as we are browsing and browser is open. Everytime I need to enter values and click Ok. This can be handled only through Function call and select Popup-Window in recovery scenario. Could you pls give an detailed example like above? I am struck at this point. Thanks in advance.

Reply

victor August 12, 2010 at 11:13 am

Hi,

I have a little problem with the recovery scenarios, I saw that all the arguments are getting lost after finish the recovery scenario, do you know if there is a way to use one of these arguments, for example retVal?

Thanks

Reply

Anshoo Arora August 22, 2010 at 4:32 pm

Victor,

Do you mean after the RS is triggered, and ran completely? You can create a global variable to store the value or use an Environment variable..

Reply

kiran July 13, 2010 at 7:44 pm

Hi,

I created a recovery scenario for “object not found” but still qtp is throwning an error instead of calling recovery function..can you help me on this

Reply

Anshoo Arora July 14, 2010 at 3:23 pm

Kiran,

Have you configured your Recovery Scenario in the Test Settings to run on every step? Also, what did you select as the Trigger condition?

Reply

bcgi June 20, 2010 at 7:18 am

Hi Anshoo,
I am regular follower of your site.I learned a lot.Actullay my problem is in my application there are 5 to 6 edit boxes which will take defferent data means one box taking alphabets and other one will take alphanuemaric.total test data is data driven.if i send any improper data an error message is getting displayed.I want to handle this with REcovery scenario.(if i give improper data also it will take properdata )my aim is script will not stop with respect to data.Can you give me any idea how to handle this
waiting for your responce
Thanks

Reply

Anshoo Arora June 22, 2010 at 12:14 pm

What kind of error does the application throw if invalid data is entered? You can create a Recovery Scenario function with the business logic to handle this kind of error – however, you must make sure there is a trigger event to this operation because Recovery Scenarios will not work without a trigger event.

Reply

Preeti June 14, 2010 at 11:32 pm

Hi Ansoo,

Any idea about How to add a function lib relatively with a recovery scenerio

Regards

Reply

Venkat June 21, 2010 at 8:45 am

Hi Preeti,

You can associate function library to a recovery scenario from the Recovery Scenario wizard available in QTP. Once the trigger event is set we can add corresponding recovery scenario operation to be executed upon the trigger event (Add respective Function in .qfl file – in Recovery Operation – Function call wizard)

Regards,
Venkat…

Reply

Anshoo Arora June 22, 2010 at 12:12 pm

Thanks Venkat :)

Reply

Vishal Jhaveri May 31, 2010 at 5:42 am

Hi Anshoo,
I want to associate the following function with my recovery scenario via function call. and then proceed to next action iteration.
However qtp accepts only accepts (Object, Method, Arguments, retVal) arguments.
Is it possible to associate the following function. Please suggest a way to do this.
Function CloseAllBrowsers()
Dim WshShell, oExec
wait(2)
Set WshShell = CreateObject(“WScript.Shell”)
Set oExec = WshShell.Exec(“taskkill /f /im iexplore.exe”)
wait(2)
End Function

Please reply soon….Very urgent
Thanks,
Vishal Jhaveri

Reply

Anshoo Arora June 22, 2010 at 10:25 am

Hi Vishal,

Try this:

Function CloseAllBrowsers(Object, Method, Arguments, retVal)
	Dim WshShell, oExec
	wait(2)
	Set WshShell = CreateObject("WScript.Shell")
	Set oExec = WshShell.Exec("taskkill /f /im iexplore.exe")
	wait(2)
End Function

Reply

Venakt April 23, 2010 at 1:11 am

Hi Anshu,

I have a small doubt related to recovery scenarios. Actually QTP does not support calling actions in any functions. But can I manually point to an action in a recovery scenario function. Such that when recovery is been kicked it has to run the specific function which internally executes an action.
Is this supported. If so are there any other side effects on using using this. If not supported how can we call an action when a recovery is been called.

Please help me out in this.

Thanks,
Venkat

Reply

Anshoo Arora April 25, 2010 at 3:12 pm

Actually QTP does not support calling actions in any functions.

It can be done through RunAction. Not sure if there will be any side affects; it depends on your action. What if the RS is triggered several times in your test? Would you like the Action to be called each time?

Reply

Anonymous April 19, 2010 at 10:53 am

Thanks a lot Anshoo, Sophie

Reply

Anshoo Arora April 25, 2010 at 3:06 pm

:)

Reply

Sophie April 18, 2010 at 2:20 pm

Thanks a lot Anshoo, that makes from grey to white, I made this duplicate submission as there was some problem with the submission, i don’t know how to delete it?

I have one more general doubt, Is there any posibility to run several test at a time thru QTP? If yes, could plz guide.
Could you plz even suggest some referal for learning QC.

Thanks in advance!, the word “thank you” is not enough for this kind of support you are giving to people like us, i got lot of hope and motivation after looking this site interms of learning QTP. If possible, please help us to get some knowledge on Vitual Objects, AOM,DOM..etc
Thank you ,
Sophie

Reply

Anshoo Arora April 19, 2010 at 5:25 am

Sophie,

I have removed the duplicate comment.

To run several tests through QTP, please see this POC from my dear friend Meir: http://www.advancedqtp.com/forums/index.php?topic=197.msg864#msg864

Reply

Sophie April 16, 2010 at 11:05 am

Hi Anshoo,

I was just looking this kind of example to understand the recovery scenario, Thanks a lot , U r post are so wonderful and gift to all desperate learners of QTP.

Could you please help me out in this?
1. In above script what is the path mentioned in screen shot No. 7(top to bottom), Function Library(which is existing, where can we get this from?
2. how does these 2 options differs?
1. Add scenario to current test
2. Add scenario to default test settings
3. Does save settings will save the written function in function library.

Thank You,

Sophie

Reply

Anshoo Arora April 17, 2010 at 10:46 am

#1. You can create a .VBS/.QFL/.TXT file and use that file to load your Recovery Scenario function.

#2.1. Adding it to the current test means, it will be used with the current test only.
#2.2. Adding it to the default test setting means, it will be used with all tests created on your machine.
#2.3. Yes.

:)

Reply

Lohith March 9, 2010 at 11:47 pm

How to parameterise the Recovery Scenario files into the Driver Script?
How to redirect the Test Result to the Excel sheet?

Please let me know at the earliest….

Thanks,
-Lohith

Reply

Anshoo Arora April 17, 2010 at 10:44 am

Parametrize a Recovery Scenario? Not sure I understand..

How to redirect the Test Result to the Excel sheet?

You would like to export all steps, or only the status? With QTP 10, you can export results to an HTML file, .DOC and .PDF files through the Result Viewer facility itself.

Reply

Bhavi January 6, 2010 at 11:56 am

Hi Anshoo,

When i start browsing your blog my time pass so fast and you have so good examples, solution where i do suggesting my jr.qa to your blog.Thanks so much and all the information so helpful.

Thanks,
Princess!

Reply

Anshoo Arora January 7, 2010 at 4:03 am

Thank you! I’m glad you found the content on RelevantCodes helpful. :)

Reply

Stefan December 23, 2009 at 4:11 am

By the way, finding/selecting an list item is especially a problem with QTP 10 and doesn’t work with SAPList objects:

Browser(“ABC”).Page(“ABC”).Frame(“ABC”).SAPList(“001″).Select “04″
and the error message is cannot identify 04 element of SAP List 001. Check if it is available in list of all elements.

I haven’t found any solution, maybe someone else has a workaround or helpful answer fixing that problem.

Thanks in advance!

Reply

Anshoo Arora January 1, 2010 at 3:22 am

Hi Stefan,

I haven’t had a chance to work with SAP, but I hope someone reading this comment section may be able to help. Consequently, you can even refer to one of the forums to have your query answered.

Reply

Ramesh December 2, 2009 at 11:44 am

I asked this same question in SQAforums.com :)

Reply

Anshoo Arora December 2, 2009 at 5:26 pm

I was wondering if that was you on SQAForums. :)

Reply

Ramesh December 2, 2009 at 11:14 am

I am using QTP 9.2. After I clicked Resources -> Recovery Scenario Manager, Recovery Scenario window is displayed. And in this window the “New” button on the does not work. Hope you noticed it. I don’t know if they fixed it QTP 10 version.

Reply

Anshoo Arora December 2, 2009 at 11:18 am

Ramesh,

You’re absolutely correct, and this is the same in QTP 9.5 as well. I’m not sure that that button is supposed to do, since there is a seperate buttom right underneath it to create a new scenario.

Reply

testking December 2, 2009 at 12:14 am

Hi Anushoo,

One of my friend said creating recovery scenario will eat time and will lead to performance issue??? How far it is true. Guide me Anshoo.

Thanks

Reply

Anshoo Arora December 2, 2009 at 11:17 am

This may be true, but I have never tested the performance of my scripts with and without the Recovery Scenarios I use, so, I can’t be entirely sure of this. I think a little bit of performance impact is not a problem as long as my Recovery Scenarios are bridging the gap between the bugs I create in my code :)

Reply

RAJ December 1, 2009 at 4:35 am

I created around 20 QTP scripts. While creating them i didn’t know about recovery scence.
Know I created one Recovery Scenario, but I want it to applicable to all earliar 20 sceipts.

How can I do this.

Pease help me.

Reply

Anshoo Arora December 1, 2009 at 6:10 pm

Hi Raj,

There are 2 ways this can be done:

1. Use AOM to associate your Recovery Scenarios with Tests. See here. The only way you can add Recovery Scenarios programatically is through an external VBS file as demonstrated in the link at SQAForums.
2. Manually associate them..

Reply

Syed November 17, 2009 at 9:30 am

Thanks a lot Anshoo Arora. this code will simplify my life of constant error messages i receive due to object not found in the items list.

Thanks,
Syed

Reply

Anshoo Arora November 17, 2009 at 9:58 am

Thank you, Syed! I’m glad it helped.

Reply

Amardeep November 8, 2009 at 2:27 am

Hi Anshoo,

I was just looking the kind of example to better understand the rs.You have Wonderfully explained the concept with relevant yet simple to understand example.Keep it up.Thanks a lot.

Regards
Amardeep

Reply

Anshoo Arora November 8, 2009 at 9:16 pm

I’m glad it helped you, Amardeep. Thank you.

Reply

Rathod November 6, 2009 at 9:35 pm

Hi Anshoo ,
I am new to qtp and until now i just know only tht pop up recovery scenario.Thank you very much for your time to prepare detailed description of this recovery scenario.This is defiantly very useful to everyone working on qtp.
One thing for me is not clear.Why are you selecting the item which is not in the list? When the item is not in the list why to select it?
Can you explain me where exactly we need to use this recovery scenario.

Reply

Anshoo Arora November 6, 2009 at 9:48 pm

Hi Rathod,

Actually, this post is just a demo of how a function call can help in such situations with Recovery Scenarios. In reality though, the example stated in this post is a complete possibility.

Let’s suppose you are creating an automated test for a Checkout process of a Shirt. The test case says that you would Checkout an Orange color shirt for size “L”. In the selection list, generally there are 4 sizes: S, M, L, XL.

However, for an Orange Color shirt, only sizes “M” and “XL” are left. Sizes “S” and “L” are all sold out.

Now, your script runs and tries to find and select size “L” from the listbox. But, as we mentioned above that size “L” does not exist. Because of this dynamic behavior of the application, QTP will still try to select item “L” (which is not there). Instead, it will throw a run error and cause the script to halt.

However, because we have created this Recovery Scenario, it will choose either size “M” or “XL”, and move on. In other words, it will save us from something we did not expect – which is the core concept of a Recovery Scenario.

Reply

Petr November 6, 2009 at 9:15 am

Hi Anshoo,
I like your articles a lot. Thank you for your effort to propagate the knowledge.
I have a question about Error Handling in QTP scripts. Do you ever use “On Error Resume Next” construct in your scripts? I look through most of your articles and cannot find any info on it. What do you think about it?
Thank you,
Petr

Reply

Anshoo Arora November 6, 2009 at 9:40 am

Excellent question, Petr.

Actually, I do use “On Error Resume Next” quite a bit. However, you do not see a lot of it in my articles because I feel its not an efficient way to handle errors, and even though I know people use it, I try not to reinforce its use :)

When the deadlines are tight and the pressure builds up, I feel I use it more then as compared to when things are going quite smooth, which gives me more time to make my code robust. I have a few functions that do a lot of error handling with simple Conditional Blocks, but a lot of my core code in my framework runs within On Error Resume Next statements.

Also, in short, the more generic my framework, the greater the use of it. However, that also means, it can become very difficult to catch an error which you would easily find, without its use.

Reply

suni October 28, 2009 at 7:43 am

Hi Anshoo,

I agree with you..we can associate recovery scenarios for any kind of scenarios as explained above ..

cheers
suni

Reply

Anshoo Arora October 28, 2009 at 10:05 am

Cheers, Suni :)

Reply

suni October 27, 2009 at 8:19 am

Hi Anshoo,

The usage of recovery Scenario is explained very clearly…the script wil fail again if the code depends on the selected list item which is not there in the list.Hence we run the suite that checks the master data first and then the main suite…

thanks
suni

Reply

Anshoo Arora October 27, 2009 at 8:55 am

Hi Suni,

How have you been?

the script wil fail again if the code depends on the selected list item which is not there in the list.

Absolutely correct. However, if the script encounters such error again, it will trigger the Recovery Scenario (again). In other words, unlike our normal code which is Single Threaded, Recovery Scenarios work more like a Try…Catch mechanism.

Reply

Deepak October 27, 2009 at 5:01 am

Hi Anshoo,
i like ur articles a lot informative and wants some detailed information on Keyword driven framework and howz it can be implemented
Regards
Deepak

Reply

Anshoo Arora October 27, 2009 at 12:53 pm

Hi Deepak,

Its quite hard to sum up the concepts and complexities of any sort of a framework that easily. However, you can find some information on Keyword-driven Testing here. Also, I would recommend you to visit AdvancedQTP’s KnowledgeBase and download FramworkManager. I’m sure these 2 sources will provide you ample information to begin with. If you have any questions in the meantime, please post here and I will try my best to help you.

PS. You should really check out FrameworkManager.

Thanks- Anshoo

Reply

Satishkumar Dega October 27, 2009 at 1:45 am

Hi Anshoo,
I appreciate the work being done by you for the QuickTest newbie’s.Anshoo,as a member of AdvancedQTP forum, your solutions for the queries are very simple and easily understandable even for the newcomers. Great Job!
I am strated to learn QTP in my own way could please help me regrading below topics with screen shots or any vedio that is good for me.
please give me one real time example in using Inputparmeters and out put parameters in QTP and aslo explain the using mutiple action using those things I need step by step explanation could u please provide a soluation

Reply

Anshoo Arora October 27, 2009 at 12:43 pm

Sure, Satish. I will try my best to help you. I don’t use QTP’s inbuilt parameters much, so I am not sure how good I will be able to explain it but I will try to write an article in the coming few days. Thanks.

Reply

nemo October 22, 2009 at 11:15 am

Good example.I found it very helpful.Especially the time you took to explain it step by step by inserting screen shots.
Thanks a lot.

Reply

Anshoo Arora October 22, 2009 at 9:07 pm

Thank you! I’m glad you found it useful. :)

Reply

Anonymous November 6, 2009 at 1:28 pm

It makes a lot of sense as always with your articles :-)
Thank you,

Reply

Anshoo Arora November 6, 2009 at 3:06 pm

Thank you :)

Reply

Satishkumar Dega November 9, 2009 at 7:15 am

Hi Anshoo,

could please give me one real time example in using Inputparmeters and out put parameters in QTP and aslo explain the using mutiple action using those things I need step by step explanation could u please provide a soluation.

Reply

Anshoo Arora November 9, 2009 at 4:34 pm

Hi Satish,

I rarely use Input/Output parameters and my knowledge about this is quite rusty. However, I will try to post something about them in the near future.

Thanks :)

Reply

Venkat February 26, 2010 at 12:55 am

Hi Anshu,
I appreciate your interest in responding to the questions and your articles too….

I have a small doubt based on recovery scenarios. Here is the brief demonstration of it.

I have a piece of code which causes my script to fail (as it is known issue… I cant handle this through the script(constraint) ) I have written a recovery scenario(RS1) and it triggered properly when any error arises. Later I enhanced my script to capture my error which QTP throws during run time and depending on the error I want script to trigger recovery scenario (RS2). Is that possible …? (I have associated both the recoveries to the test…What I observed is it is running both the recovery scenarios whenever any error arises in the script).

One more doubt is how does ‘recovery scenarios’ differ from the ‘When error occurs during run session: Proceed to next step’

Reply

Anshoo Arora February 28, 2010 at 5:54 pm

One question: If you can’t handle it through your script, how can you handle it through your Recovery Scenario? Wouldn’t the same code be applied in the situation where this constraint occurs?

. Later I enhanced my script to capture my error which QTP throws during run time and depending on the error I want script to trigger recovery scenario (RS2).

It may be. I am going to do some research on this and get back to you, but my initial thought would be that this might just be possible..

One more doubt is how does ‘recovery scenarios’ differ from the ‘When error occurs during run session: Proceed to next step’

When error occurs during run session: Proceed to next step is a subset of Recovery Scenarios. A Recovery Scenario has the functionality to let users to proceed to the next step when their core-recovery-scenario-action is performed.

Reply

Venkat March 2, 2010 at 5:22 am

Hi Anshu,

I can handle the script by modifying it (which is a hectic problem for me..I just want my existing scripts not to be modified but want them to be handled through recovery scenarios…). So I tried in this track for a better solution and found few problems which I have mentioned in my earlier post.

Thanks,
Venkat

Reply

Anshoo Arora March 2, 2010 at 4:28 pm

Gotcha. I will try do some research on this and post my observations here. But, technically, what you’re trying to do should be possible..

Reply

Venkat April 26, 2010 at 11:55 pm

Thanks Anshoo.. I did try with RunAction earlier and it worked fine for me..but because of this I got some problems in reporting mechanisms. Is there any other way where I can invoke an action in the function…?

Thanks,
Venkat.

Reply

Anshoo Arora April 28, 2010 at 2:45 am

Sure you can. The same process as you would do from a Function Library would be implemented here, but instead of keeping code loose, we’ll store it in a function so it only executes when the function is called. What issues did you have with reporting?

Reply

victor September 1, 2010 at 5:06 pm

Thanks a lot…. it works with the environment variables

Reply

harisha gowribidanur March 24, 2011 at 1:14 am

hi, this is harish from bangalore.

i’m using recovery scenerio for a pop up java window…

but its an alert action….it will come many num of times with a gap of less than a second…..

how much time will the qtp takes to identify the pop up window and to perfom the closing operation on that java window…..

or is there any other methods to handel this type of situation…that is

during test run ,a java window will come any any point of time,we need to close it as and when it comes and

the test should run smoothly.

Reply

Previous post:

Next post: