• Tech Travel Hub is your one stop, ultimate tour guide to all things tech, travel, visas and digital nomads
  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact
Menu
  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact
View Blog
April 6, 2023April 6, 2023

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

    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
    EventStatus

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

    ConstantnumberMeaning
    micPass The 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.
    stepName:

    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.

    pathToSaveTheScreenshot:

    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()?

    errorFile="D:\Test\"&testName&".png"
    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.

    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"

    or

    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
    a=10
    b=15
    myVar=a+b
    If(myVar=25) then
    Reporter.ReportEvent micPass,"verify Addition","Calculator is working"
    else
    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
    ExitTest
    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.

    Reporter.RunStatus=micPass/micFail
    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:

    Reporter.FilterProperty=newMode
    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.

    ModeNumberMeaning
    rfEnableAll It 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

    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='http://techtravelhub.com>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.

    ReporterEvent.

Post navigation

Previous post
Next post

Umer Umer

Leave a Reply Cancel reply

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

Recent Posts

  • Simplified Concept on What Is Interface In Java: Detailed Facts In 5 Minutes
  • What is Integration Testing?
  • What is GEB-Groover Browser Functional Testing?
  • What is GEB- Detailed Facts in Just 5 Minutes
  • What is Extreme Programming(XP) Practice?

Categories

  • Adventure
  • Agile Methodology
  • All world Tour
  • Android Development
  • Ansible
  • App
  • App Development
  • Artificial Intelligence
  • AWS
  • Bitcoin
  • BlockChain
  • Blogging
  • Box Packing
  • Business
  • business
  • Business Communication
  • buying guide
  • C
  • car
  • Care
  • Certification
  • Certification
  • Chatbot
  • cinema
  • Cloud Tech
  • Content Marketing
  • Corporate
  • covid-19
  • crucible
  • Cryptocurrency
  • Database
  • DevOps
  • DevOps
  • Digital Marketing
  • Drawing
  • Dress
  • Educational
  • Employment
  • Entertainment
  • Exceptions In Java
  • Fashion
  • Festivals
  • Finance
  • Fitness
  • Food
  • Game
  • Gift ideas
  • Groovy
  • Health
  • Health
  • home
  • home improvement
  • HR
  • IllegalThreadStateException in Java
  • India Tour
  • Instagram
  • Ios
  • ISO
  • Java
  • Javascript
  • job
  • Kids Section
  • Kitchen
  • Law
  • Life Style
  • Lifestyle
  • Lifestyle Home Improvement
  • Main Stories
  • Management
  • Mattress
  • Motorable
  • Movie
  • nursing
  • Pendrive
  • Perspective
  • Pet
  • Popular
  • Programming
  • Python
  • Relationships
  • Selenium
  • SEO
  • Skin
  • SOAPUI
  • Social Media
  • Social Media Marketing
  • Software
  • software development
  • Software Development Model
  • Software Engineering
  • Software Testing
  • Sports
  • Startup
  • T Robot
  • TDD
  • Tech
  • Tech News
  • Tech News
  • Technology
  • Tool
  • Tour Guide
  • Tour Guide
  • Travel
  • UFT
  • Uncategorized
  • USB Cable
  • VPN
  • Web Development
  • Wordpress
  • Yoga
  • Youtube

Tags

Instagram Instagram Marketing Marketing SEO Thoptv App

Categories

  • Tech
  • Travel
  • Visas
  • Digital Nomad
  • Tech
  • Travel
  • Visas
  • Digital Nomad

Publishing

If you would like to publish on our site, please email admin@techtravelhub.com

Quick Links

  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact
  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact

Contact

Tech Travel Hub LLC

Address:
8 The Green STE A
Dover
Delaware, 19901

Phone: +1 302 956 9948