Pages

Wednesday, April 27

QTP Reporter Object - Send messages to QTP Result file

Hello Friends!


In this post, we'll see how to customize and manage the information in QTP Test Result file. Test Result is automaticaly generated after every test run.


Reporter Object is used for sending information/message to the QTP test results. Following are the method/properties we can use with ‘Reporter’..


•    ReportEvent Method
•    Filter Property
•    ReportPath Property
•    RunStatus Property


ReportEvent Method


ReportEvent is commonly used method od Reporter and most of you must be already aware of this!

As the name suggest, it reports an event to the test results. Means, by using Reporter.ReportEvent, you can send information to QTP test result file.

Syntax:
Reporter.ReportEvent EventStatus, ReportStepName, Details

As we can see above, ReportEvent takes 3 arguments. Let's discuss these briefly-


EventStatus:  Status of the step i.e. Pass/Fail etc. It can be four types..


0 or micPass: Causes the status of this step to be passed and sends the specified message to the report.

1 or micFail: Causes the status of this step to be failed and sends the specified message to the report. When this step runs, the test fails.

2 or micDone: Sends a message to the report without affecting the pass/fail status of the test.

3 or micWarning: Sends a warning message to the report, but does not cause the test to stop running, and does not affect the pass/fail status of the test

ReportStepName: It is name of step. It can be any string value.

Details: It is also any string value. You should provide description of steps here.

Example of ReportEvent Method

The following examples use the ReportEvent method to report a failed step.

Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."
or
Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."

You can leave last two arguments (ReportStepName and Details) blank as well but recommended.

Reporter.ReportEvent 1, "", ""
or
Reporter.ReportEvent micFail, "", ""


Okay friends! It was most important part of Reporter. Let's quickly discuss remaining three properties also.


Filter property

Using Filter property, you can instruct QTP about what type of event to display in result.

Syntax:
Reporter.Filter = Mode


What is the use of Filter property?

Filter is used if you dont want to display all types of events in QTP test result. For example you have 10 Reporter.ReportEvent statements in your test (5-
Pass and 5-fail). By default all 10 will be displayed in result. You can use Filter if you want to display only pass or only fail events in the result. One way to comment all unwanted type of Reporter statements, but what if you can do that by writing just one line in your code!


There can be four types of Filter modes..

0 or rfEnableAll: This is the default mode. All reported events are displayed in the Test Results.

1 or rfEnableErrorsAndWarnings: Only those events with a warning or fail status are displayed in the Test Results.

2 or rfEnableErrorsOnly: Only those events with a fail status are displayed in the Test Results.

3 or rfDisableAll: All events in the Test Results are disabled. No event will be displayed in result file.


Example of Filter Property:

Reporter.Filter = 2
or
Reporter.Filter = rfEnableErrorsOnly



ReportPath Property


It simply retrieves the folder path in which the current test's results are stored.

Do not use this property to attempt to set the results folder path. Means it is used for 'getting the path' not 'setting the path'.

Syntax:
Path = Reporter.ReportPath


Example of ReportPath Property

Dim Path
Path = Reporter.ReportPath
MsgBox (Path)

Above example uses the ReportPath property to retrieve the folder in which the results are stored and displays the path in a message box.


RunStatus Property

It retrieves the run status at any particular point during the run session. For tests, it returns the status of current test during the test run.

Syntax:
Reporter.RunStatus

Example of RunStatus Property

If Reporter.RunStatus = micFail Then
  Msgbox "Run Status is fail. Exiting from Action iteration."
  ExitAction
End If


Above example uses the RunStatus property to retrieve the status of the run session at a specific point and exit the action if the test status is fail. If the test status is not fail, the test run continues.

In case of any queries/suggessions, please post your comments.

16 comments:

  1. Nice explanation.

    ReplyDelete
    Replies
    1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

      IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

      corporate training in chennai corporate training in chennai

      corporate training companies in india corporate training companies in india

      corporate training companies in chennai corporate training companies in chennai

      I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai

      Delete
  2. thanks for explanation

    ReplyDelete
  3. Hi
    can u plz help me to ans these questions.


    1)Why we import the data from excelsheet to datatable and using it as datatable parameter...while we can use the value directly from excel sheet using excel application model .

    or

    What is the advantage over using datatable input over excel input in our script?

    2) How to log defect after executing a script in qtp ?

    ReplyDelete
  4. @Ranjan

    Exporting sheets to datatable have several benefits of its own, for example..

    Its more convenient at the time if you have lots of columns in the datatable. By importing shhets to Datatable, you can refer column by its name (which is not feasible to do using Excel COM)

    ReplyDelete
  5. Hi, gud explanation,
    can u tell me how to wrap reporter.reportevent in a function .. so that it can be called and passed arguments whenever required in the script

    ReplyDelete
  6. Hi ,can i delete all temp files directly from temp folder in QTP?
    if i delete is there any problem to face while running the script?cause my QTP became very slow... pls help me...

    ReplyDelete
  7. You can tell for instance if the understudies are rehearsing moves for self preservation or on the off chance that it is rivalry sort of preparing. Likewise you can see whether they are about youngster or grown-up preparing. taekwondo school in lees summit mo

    ReplyDelete
  8. Nice information and bery useful for all of us.
    https://www.acte.in/reviews-complaints-testimonials
    https://www.acte.in/velachery-reviews
    https://www.acte.in/tambaram-reviews
    https://www.acte.in/anna-nagar-reviews
    https://www.acte.in/porur-reviews
    https://www.acte.in/omr-reviews
    https://www.acte.in/blog/acte-student-reviews

    ReplyDelete
  9. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete
  10. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too please do keep sharing more blogs like this.

    IELTS Coaching in chennai

    German Classes in Chennai

    GRE Coaching Classes in Chennai

    TOEFL Coaching in Chennai

    spoken english classes in chennai | Communication training



    ReplyDelete
  11. Excellent Blog! I would Thanks for sharing this wonderful content.its very useful to us.I gained many unknown information, the way you have clearly explained is really fantastic.keep posting like this information.
    Full Stack Training in Chennai

    Full Stack Course Chennai
    Full Stack Training in Bangalore

    Full Stack Course in Bangalore

    Full Stack Training in Hyderabad

    Full Stack Course in Hyderabad

    Full Stack Training

    Full Stack Course

    Full Stack Online Training

    Full Stack Online Course

    ReplyDelete