Micro Focus QTP (UFT) Forums
Getting Error Details in QTP - 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: Getting Error Details in QTP (/Thread-Getting-Error-Details-in-QTP)



Getting Error Details in QTP - chetandahale - 09-30-2010

Hi All,
I have implemented error handling by descriptive programming in my driver script using

qtApp.Test.Settings.Run.OnError = "NextIteration"

I am calling every action to execute using "LoadandRunAction" function.

Now I want to get the error details like number, description of the error which will occur while executing the action so that I can use that details in my driver script to write a result in an excel..like the action is executed completly or not.

I tried using recovery scenario which will get triggred when there is any error. I called a function in that scenario to get the error detail like below

Code:
Function RecoveryScenario()
RecoveryScenario = Err.number
End Function

Called the above function in my driver script using

ErrNum = RecoveryScenario

But though there is an error while executing the an action the above funtion returns 0. Which means everything is fine and there is no error.

I am not able to capture the error details and use them in my driver script.

Thanks for the help in advance !


RE: Getting Error Details in QTP - guin.anirban - 09-30-2010

Use Err object to get the details. Like Err.Number or Err.Description


RE: Getting Error Details in QTP - chetandahale - 10-01-2010

I already did that..but its not working.


RE: Getting Error Details in QTP - tdevick - 02-23-2011

I believe you are clearing the error values when you call the function. If this were a normal function, you could pass it the Err object and I think you would preserve your error information. Since this function is triggered by an error in the script and you can't control the parameters (I don't think you can), I don't think this is going to work.

In the QTP 10 help, you can find "Recovery Scenario Wizard, Function screen" and it will show you useful info on creating a recovery functiton. It says that the recovery function for a test run error has the first parameter as an object that represents the object that had the error. One of this object's attributes is "Result" which is defined as "The actual method's results". I'm guessing that this is probably your error number.

After you select a function library, choose one of the following options:

Select function. Choose an existing function from the function library you selected.
Only functions that match the prototype syntax for the trigger type selected in the Select Trigger Event Screen are displayed.

Following is the prototype for each trigger type:

Test run error trigger
OnRunStep
(
[in] Object as Object: The object of the current step.
[in] Method as String: The method of the current step.
[in] Arguments as Array: The actual method's arguments.
[in] Result as Integer: The actual method's result.
)

Pop-up window and Object state triggers
OnObject
(
[in] Object as Object: The detected object.
)

Application crash trigger
OnProcess
(
[in] ProcessName as String: The detected process's Name.
[in] ProcessId as Integer: The detected process' ID.
)




RE: Getting Error Details in QTP - tester_rahul - 02-23-2011

I am not sure what code you are using.However i can give you some idea of how to use error handling in vbscript

on error resume next ' this means that if an error occurs the execution will not stop and proceed to the next line
< lines of code which would raise the error>
if err.number <> 0 ' which means that some error has occurred
msgbox err.description
else ' this condition is reached if no error has occurred
<your code logic if no error occurs>
on error goto 0 ' this stops your error handling code


please let me know if you have problem in understanding this code.