How to work with Reporter Object in QTP or UFT

How to work with Reporter Object in QTP or UFT?

This post talks about reporter utility object in UFT,reporter object in UFT,UFT Reporter Objects with Examples,how to use Reporter.ReportEvent,syntax for reporter object in UFT.

A reporter object in UFT responsible for storing information related to test outcome to the run result.Reporter Object in UFT supports various methods and properties that are used in runtime to showcase the results.A reporter Object can change the control of the flow depending on outcome.

So a Reporter Object is responsible for the following:
  • Report test status
  • Enable or disable reporting
  • Get the folder path from where the test is running.
  • Fetch the run status.
  • Report custom test result and update the run result

Methods available in Reporter object in UFT:

  • ReportEvent() method
  • ReportNote() method
  • ReportHtmlEvent() method
See also  Object Repository Concept In Selenium

Properties available in Reporter object in UFT:

  • Filter property
  • Run status property
  • Reportpath property

Details of ReportEvent() method:

ReportEvent() method accepts four parameters

  • EventStatus
  • stepName
  • stepDetails or stepDescription
  • pathToSaveTheScreenshot
The syntax of ReportEvent() method or syntax for reporter object in UFT:
Reporter.ReportEvent EventStatus, stepName, stepDetails,pathToSaveTheScreenshot

Now EventStatus can be of 2 types(Primarily) and can be expressed as a constant or a number.

micPassThe step is passes and sends a pass signal to the run result.
micFail1The step is failed and sends a pass signal to the run result.
micDone2The step is completed and sends a completion signal to the run result.
micWarning3The step is completed with a warning and sends a warning signal to the run result.

It accepts a String parameter and accepts the custom step name that the user wants to display in the run result.

stepDetails or stepDescription:

It also accepts a String parameter and accepts the custom step details that the user wants to display in the run result.


It also accepts a String parameter that specifies if the coder wants to save the screenshot where UFT will place the result.

The image format supported by UFT are as follows:

  • .bmp
  • .jpeg
  • .png
  • .gif

However, it is an optional parameter.It is also not a good practice to capture screenshot in every step. That process may end up accumulating lots of screenshots. This will also have a impact on space and reporting time. So it is best when we only take screenshot if a test failed.

How to capture a screenshot and use in the Reporter.ReportEvent()?

Browser("Login").Page("Login").CaptureBitmap errorFile,True 'True will overwrite an existing file'
Reporter.ReportEvent 1,"login test","Check if the page has id field",errorFile

We can also write a method to do the same by passing the file name and object name.

See also  Which is better Xpath or DOM?

so the reporting will be ..

syntax for reporter object in UFT
Reporter.reportEvent 1,"User can not see the image" ,"Test case failed due to unavailability of the image"


Reporter.reportEvent micPass,"User can not see the image" ,"Test case failed due to unavailability of the image"
Example of ReportEvent method or how to use Reporter.ReportEvent?
Option Explicit
Dim myVar,a,b
If(myVar=25) then
Reporter.ReportEvent micPass,"verify Addition","Calculator is working"
Reporter.ReportEvent micFail,"verify Addition","Calculator is not working"
End if

Below are the reporter utility object in UFT:

Reporter.RunStatus Object

Reporter.RunStatus object provides the insights of the status of the current test run.We can further control the execution based on the outcome of the Reporter.RunStatus value.

Example of Reporter.RunStatus/UFT Reporter Objects with Examples

If Reporter.RunStatus=micFail Then
End If

This code will Exit the current test if the test status is failed.

How we can change the Reporter.RunStatus from code ?

From our code we can use the following code to change the status of the Reporter.RunStatus.

How to change the the mode of the test?

To change the mode of the test we need to use Reporter.Filter property.

The code will be:

How to get the current mode of the test run?

To get the current mode of the test run, we can use the following code.

msgbox Reporter.FilterProperty

UFT provides the following modes for the use of Filter property.

rfEnableAllIt is the default mode that displays all elements in the run result.
rfEnableErrorsAndWarnings1It filters out all other modes and displays only Errors and warnings.
rfEnableErrorsOnly2Displays only fails on the run result
rfDisableAll3Displays no events in the run result.


What if you are using Reporter object on Adobe Flex then reporter object may fail intermittently or if you want to track the exact line of failure than you can override the ReporterEvent.

See also  How to Work With Environment Variable in UFT?

Can we use ReporterEvent in Keyword view or how to use Reporter.ReportEvent in keyword view?

Yes,we can use ReporterEvent() method in keyword view.Here is the navigation:

  • Select the desired step and choose Insert -> Step -> Report or right-click a step and choose Insert Step -> Report.

Reporter.ReportHtmlEvent() method

Reporter.ReportHtmlEvent() method is very similar to Reporter.ReportEvent(how to use Reporter.ReportEvent) with an exception that here we can insert custom HTML element to beatify the run result. It is a nice feature to customize the traditional reporting.

Reporter.ReportHTMLEvent micDone, "<b><i><font face='Arial' color='black'>Test ReportHTMLEvent</font></i></b>", "<b><font face='Arial bold' color='green'>Reporting Some Text with Color</font></b>"

Reporter.ReportNote() method

This method enables us to send a special to note to the run result that will be visible in the executive summary Note section.It is only visible if the root node is selected.

How to control Reporter object via code?

Reporter object in UFT can be controlled by code. Here is how-Joe has mentioned.

  • Enter the following code in the Expert View of your tests:
Set oEventDesc = CreateObject("Scripting.Dictionary")
oEventDesc("ViewType") = "Sell.Explorer.2"
oEventDesc("Status") = micPass
oEventDesc("EnableFilter") = False
oEventDesc("NodeName") = "My Blog"
oEventDesc("StepHtmlInfo") = "<a href='>TechTravelHub</a>"
newEventContext = Reporter.LogEvent ("Replay",oEventDesc,Reporter.GetContext)
  • Run your test and look at the HP Run Results Viewer.

This is how to use Reporter.ReportEvent in UFT.

Share and Enjoy !

51 thoughts on “How to work with Reporter Object in QTP or UFT

Leave a Reply

Your email address will not be published. Required fields are marked *