How to show additional information at the head of Report?

Best practices, code snippets for common functionality, examples, and guidelines.
BCTest
Posts: 88
Joined: Tue Jun 03, 2014 10:15 am
Location: Hamburg, Germany

How to show additional information at the head of Report?

Post by BCTest » Fri Apr 24, 2015 3:08 pm

Hi there,

I want to add a short summary of all test-data in the head of the report. In our tests data will be prompt by Ranorex and I want to show the amount of data in the head of the report, e.g.
- 12 customers were inserted
- 10 invoices were created
...
If possible these information should be readable without expanding any test-case at the top of the report.
What will be the best way to add this data to the head of the report?

Regards,
Thomas.

User avatar
RobinHood42
Posts: 238
Joined: Fri Jan 09, 2015 3:24 pm

Re: How to show additional information at the head of Report?

Post by RobinHood42 » Mon Apr 27, 2015 2:37 pm

Hello BCTest,

You will need to use a custom report template in order to display runtime information within your report.
The runtime information can be added to the “ActivityStack” using the following lines of code:
var act =  Ranorex.Core.Reporting.ActivityStack.Instance;
			act.CurrentActivity.CustomProperties.Add("MyProperty", "MyValue");
You can add the aforementioned code to UserCodeModules or UserCodeMethods.

After that, we need to change the *.xsl file of our custom report template.
Just add the following part to the file:
<!-- Custom header information -->
	  <tr>
		<xsl:if test="//custom">     
          <td>
            <i class="field">
              MyProperty<b>
              <xsl:value-of select=".//custom/@MyProperty"/>
              </b>
            </i>
          </td>        
		</xsl:if>
	  </tr>
	<!-- END custom header information-->
Sample XSLfile:
RanorexReport5.zip
(5.84 KiB) Downloaded 96 times
The result will look like this:
CustomProperty.png
CustomProperty.png (15.21 KiB) Viewed 1470 times
Cheers,
Robin

BCTest
Posts: 88
Joined: Tue Jun 03, 2014 10:15 am
Location: Hamburg, Germany

Re: How to show additional information at the head of Report?

Post by BCTest » Tue Apr 28, 2015 8:13 am

Hello Robin,

exactly what I was looking for.

Thanks!
Thomas.

AFI
Posts: 13
Joined: Tue Feb 24, 2015 8:36 am
Location: Germany

Re: How to show additional information at the head of Report?

Post by AFI » Tue Apr 28, 2015 11:42 am

Great.
Thanks RobinHood42

User avatar
RobinHood42
Posts: 238
Joined: Fri Jan 09, 2015 3:24 pm

Re: How to show additional information at the head of Report?

Post by RobinHood42 » Wed Apr 29, 2015 1:00 pm

You're welcome :D

Cheers,
Robin