Examples of Reporter.ReportEvent in UFT

Reporter.ReportEvent Statement is used to send desired events (like Pass, Fail, etc) and custom messages in the run results of UFT.

For example, you have written the code for doing log-in to an application. After submitting the page with valid credentials, you might check whether the next page is displaying or not. If it is displaying you can report a pass event else you can report a fail event.

ReportEvent Method in UFT

It reports an event to the run results.
Syntax
Reporter.ReportEvent EventStatus, ReportStepName, Details, [ImageFilePath]
You can pass the following values for EventStatus:
0 or micPass: Cause the step to be reported as Pass
1 or micFail: Cause the step to be reported as Fail.
2 or micDone: It sends the message to the test report without affecting the Pass/Fail status of the Test
3 or micWarning: It also sends the warning message to the run results and does not affect the status of the test/component.
ReportStepName: Step name that is displayed in the Run Results window. Generally used to write the expected result.
Details: It shows the description of the run results event. Generally used to write the actual result.
ImageFilePath: This is an optional parameter.Provide the path and filename of the image to be displayed in the run results. Supported image formats are BMP, PNG, JPEG, and GIF.
For Example:

Or you can also write it in the following way:

Using the numeric value for EventStatus
‘Reporting a fail step

Capture Error Screenshot using ReportEvent

You can capture screenshots in Run Results for all EventStatus.However, capturing screenshots for every EventStatus is not advisable because it will take huge space in the hard drive and it may impact the performance as well. So it is better to capture screenshots for only failed steps.

A sample Run Result for the following code. You can see the screenshot for the failed step is displaying in the result viewer.

Reporter.ReportEvent in uft

*Note: UFT cannot load images from HP ALM. Hence save images only in your local machine or in a network location

Recommended Posts

Leave a Reply