Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Error Details in QTP
#1
Not Solved
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 !
Reply
#2
Not Solved
Use Err object to get the details. Like Err.Number or Err.Description
Reply
#3
Not Solved
I already did that..but its not working.
Reply
#4
Not Solved
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.
)

Reply
#5
Not Solved
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find System details on which uft license is utilized Ccma 1 1,038 04-24-2018, 02:16 PM
Last Post: Ankur
  Runtime variables details amitmanekar91 0 2,109 03-07-2015, 08:27 PM
Last Post: amitmanekar91
  How to get the details of the current test instance from ALM HARINSUBRU 0 2,407 09-17-2014, 08:09 PM
Last Post: HARINSUBRU
  Details of Log tracking in qtp11 sowmya 0 4,045 01-25-2012, 01:43 PM
Last Post: sowmya

Forum Jump:


Users browsing this thread: 1 Guest(s)