How to instruct QTP to display errors and other description in the test results instead of halting execution by throwing error in the mid of execution due to an error (for example Object not found)?

Showing Answers 1 - 4 of 4 Answers

Uday Kumar. A

  • Sep 13th, 2006
 

1. Here if you want the error at result window, then you can see the resultant error by using Reporter.ReportEvent.

The syntax is Reporter.ReportEvent EventStatus, ReportStepName, Details.

EventStatus - 0-Sucess, 1-Fail, 2- Just send a msg to test window, 3-warning msg

ReportStepName-Variable that returns the error

Details - You can write your own description for the Error

2. If you want to bypass that error and wants to continue with the remaining script, you can use Recovery Scenario

  Was this answer useful?  Yes

akothuru

  • Jun 11th, 2008
 

Use "On Error Resume Next" statement at the beginning of your script/function and use the following statements at the end of script/function.

 If Err.Number <> 0 Then
  ErrorNumber =" Error # " & CStr(Err.Number)
  ErrorDescription = Err.Description
  Reporter.ReportEvent micFail, "Error description: " & Err.Description, "Failed"
  Err.Clear ' Clear the error.
 End If

So that at run time, if any exception come it skip the current statement and execute the immediate next statement and at the end it sends the error description to test result screen

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions