Micro Focus QTP (UFT) Forums
Need Recoveries to handle Run Time Errors - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Need Recoveries to handle Run Time Errors (/Thread-Need-Recoveries-to-handle-Run-Time-Errors)



Need Recoveries to handle Run Time Errors - dvkbabu - 03-23-2009

I need a Recovery for the following scenario.(I am using QTP 9.2)

I have a Main VBS function in which I am calling 3 other VBS Functions within the For statement. Please see the sample code below

Code:
Public Function Main()
---
  For i = 1 to 10

   Fun1()
   Fun2()
   Fun3()

  Next

End Function

I am executing this script for "Web" Application and think for the first four iterations execution is successful, and in fifth iteration(i=5) I got a Run Time error in Fun2() which stopped the execution.

I want a Recovery for these kind of run time errors. Here I have two options I want to handle

Opt 1: Stop the Iteration(in this case 5th iteration) when the Run Error comes -> Close the Application -> Start next Iteration(6th)

Opt 2: Stop the execution of Function(Fun2()) only in which we got Run Error and continue execution of Fun3() for the Fifth iteration.

NOTE: Run Test Setting of 'Data Table Iterations' option should be 'Run One Iteration only' in this case.

Could you Please share your ideas in these kind of scenarios.? And if you want to suggest any other Recoveies in the above scenario please share.

Thanks,
Vijay


RE: Need Recoveries to handle Run Time Errors - Tarik Sheth - 03-23-2009

Try if GetNextRow or SetNextrow in the datatable helps in this situation.


RE: Need Recoveries to handle Run Time Errors - dvkbabu - 03-26-2009

I got some information on this. I am capturing Run TIme Error number in a global variable from 'Err.Number' and Validating this with IF Condition (If Err.Number<>0) and exiting the funciton based on the Err.Number value.

As I don't want my script to stop, I am using 'On Error Resume Next' statement in each function and every function.

Drawback with this is If we use any Recoveries(.qrs) then Err.Number automatically sets to a number when ever Recoviries are called.

Vijay