Exception Handling and reporting errors which occur randomly!

167 views
Skip to first unread message

jay rawat

unread,
May 21, 2012, 1:41:53 PM5/21/12
to QTP - HP Quick Test Professional - Automated Software Testing
Exception Handling and reporting errors which occur randomly:

How to report such errors which occur randomly like due to bad data
file payment don't take place for customer sometimes?
And if able to report them then how to do exception handling on such
items?
Do we need to define such errors somewhere and how to log them in
logger?

Anish Pillai

unread,
May 23, 2012, 10:11:40 AM5/23/12
to mercu...@googlegroups.com
You can try using On Error Resume Next inside a function to capture the error. At the end of the function, you can write the code to handle the error. See the below sample function.

Function fnYourFunction()
  On Error Resume Next
  '---Your Code
  '---Your Code
  '---Your Code

  If Err.Number <> 0 Then
    'Handle the error
  End Function
End Function




--
ar

jay rawat

unread,
May 23, 2012, 1:18:23 PM5/23/12
to mercu...@googlegroups.com
Brother that's what I also intend to do but then do we error IDs available for QTPs general errors:
(1) Object was Not found/ object don't exit on page
(2) Object Not Defined
(3) More than one object exist on page with similar properties
(4) General Error

Now whenever such an error gets invoked qtp shows it and if you handle it via Recovery or code it stops the run which breaks the regression
execution there itself.

Say there were 200 scripts lined up for execution and all were whole sole independent scripts. And the 50th script got an error Object not Found then the recovery/code will handle error but it will stop the execution there itself. Do you think under that condition "On Error Resume Next" statement will not let execution stop and will take execution to 51st script to execute?



--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Johnson Solomon

unread,
May 23, 2012, 11:47:47 PM5/23/12
to mercu...@googlegroups.com
Hi Jay,

If you are running those 200 scripts from QC, then you need not worry since it will suppress all the errors and it will proceed to the next step/test.

If you are not using QC, then do this setting in your QTP test: File > Settings > Run > On error : Proceed to next step

I hope this would help, but I recommend to handle all the errors in code.

Example
: Do Object.Exist and then perform any action on that object.

--
With Regards,
Johnson Solomon

Reply all
Reply to author
Forward
0 new messages