How to add info line to report header

Best practices, code snippets for common functionality, examples, and guidelines.
SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

How to add info line to report header

Post by SanMan » Tue Aug 22, 2017 9:57 am

What is the easiest way to add data from my test run (Report.info"SUT version"+ver) to my test report header?

Do I need to do it via Report Template > Create Custom Template ?

Only I want to add SUT version to header, nothing else needs to be changed...

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: How to add info line to report header

Post by SanMan » Tue Aug 22, 2017 11:15 am

Is this info still valid? :

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:
view plaincopy to clipboardprint
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:
view plaincopy to clipboardprint
<!-- 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-->


In what part in *.xls file I should add this code?

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: How to add info line to report header

Post by SanMan » Tue Aug 22, 2017 11:46 am