Motivation
The QTP native log has many drawbacks, especially if your scripts relay heavily on Functions. While Actions are reported in an hierarchical structure (i.e. nested according to their call chain), events reported by function are reported in a flat, unsorted manner. This can be illustrated by the following example:
The following QTip will allow you to report custom events in an hierarchical manner. This will allow you to achieve reports like this one:
Notice that the report is structured as an hierarchical tree, even though all the events are executed within the same action. You can decide when to open a new node, and when to report in a flat manner.
How it’s done
The technique relays on three steps:
- Creating a new node in the results tree.
- Reporting events / Creating additional sub-nodes (they will be children / grandchildren of the node we’ve created)
- Climbing back "up" the hierarchy and reporting more events (they will be siblings of the node we’ve created)
Creating a new node in the results tree:
'dicMetaDescription will hold our new node’s detailsSet dicMetaDescription = CreateObject("Scripting.Dictionary")'Set node statusdicMetaDescription("Status") = MicDone'Set node’s headerdicMetaDescription("PlainTextNodeName") = "A node with children"'Set the node’s details. HTML is alloweddicMetaDescription("StepHtmlInfo") = "<DIV align=left><H1>HTML layout testing</H1><b>This</b> can be handy to have.</DIV>"'Some backdoor settings:dicMetaDescription("DllIconIndex") = 206dicMetaDescription("DllIconSelIndex") = 206dicMetaDescription("DllPAth") = "C:\Program Files\Mercury Interactive\QuickTest Professional\bin\ContextManager.dll"'If you’re using QTP 9.5, replace the previous line into:'dicMetaDescription("DllPAth") = "C:\Program Files\HP\QuickTest Professional\bin\ContextManager.dll"'Actually do the report, and get the new report node IDintContext = Reporter.LogEvent("User", dicMetaDescription, Reporter.GetContext)'Set the new report node as a parent'From now on, all reports will be added under this nodeReporter.SetContext intContext
Reporting Events:
This is done the old fashion way:
Reporter.ReportEvent MicPass, "Some Header", "Some Details"
If we’d like, we could open new nodes under our current node by repeating step 1.
Climbing up the hierarchy:
After reporting a few events under the current node, we’d like to "climb up", and report the following events in a higher level (i.e., no longer under the node). You may need to do this several times in order to return to the report’s "top" level, depending on the number of sub-nodes you’ve created in your report.
'Now return to the parent level:Reporter.UnSetContext
*This article is based on stalis’s post in SQAForums
Posted in Reports


Yaron Assa




April 29th, 2008 at 10:11 pm
Can we read content we set the same way?
April 30th, 2008 at 4:43 am
Excellent question.
As far as I know - no…
May 27th, 2008 at 2:42 pm
Thanks for the info (thanks to Stalis as well).
When using functions instead of actions this method is very useful in order to group your QTP reporting.
Here is a tip how to set font-size when using element in Stepinfo:
dicMetaDescription(”StepHtmlInfo”) = “” & strYourTableRowInfo & “”
May 27th, 2008 at 2:45 pm
Reposting due to problems with quotation marks (hope it works better this time):
dicMetaDescription(”StepHtmlInfo”) = _
“” &_ strYourTableRowInfo & “”
May 27th, 2008 at 2:51 pm
Last try (sorry for spaming, forgot about escaping HTML elements):
dicMetaDescription(”StepHtmlInfo”) = “<DIV align=left><TABLE STYLE=”"font-size: 8pt”">” & strYourTableRowInfo & “</TABLE></DIV>”