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.ReportPathExample 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.RunStatusExample 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.
Nice explanation.
ReplyDeletethanks for explanation
ReplyDeleteHi
ReplyDeletecan 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 ?
@Ranjan
ReplyDeleteExporting 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)
Hi, gud explanation,
ReplyDeletecan 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
Hi ,can i delete all temp files directly from temp folder in QTP?
ReplyDeleteif i delete is there any problem to face while running the script?cause my QTP became very slow... pls help me...
This comment has been removed by the author.
ReplyDeleteYou 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
ReplyDeleteNice information and bery useful for all of us.
ReplyDeletehttps://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
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.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training
Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work. nice to read.
ReplyDeleteselenium training in chennai
selenium training in chennai
selenium online training in chennai
selenium training in bangalore
selenium training in hyderabad
selenium training in coimbatore
selenium online training
selenium training