Adding Variable Value to Custom Report Template

Ask general questions here.
Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Adding Variable Value to Custom Report Template

Post by Fergal » Wed Apr 26, 2017 11:07 am

My test suite has a Test Case, that gets the version number of the SUT and assigns it to a variable called versionNumber.

The code below adds the name of the Windows logged in user to the Custom Report:

Code: Select all

<xsl:value-of select="@user" />
What code can be added to the custom report, to add the value of the versionNumber variable?

Thanks!

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

Re: Adding Variable Value to Custom Report Template

Post by RobinHood42 » Thu Apr 27, 2017 11:21 am

Hey Fergal,

You would need to add a custom property to the activity stack:
var act =  Ranorex.Core.Reporting.ActivityStack.Instance;
           act.CurrentActivity.CustomProperties.Add("MyProperty", "MyValue");
That property can then be addressed within your XSL file:
<xsl:value-of select=".//custom/@MyProperty"/>
Hope that helps.

Cheers, Robin 8)

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Adding Variable Value to Custom Report Template

Post by Fergal » Thu Apr 27, 2017 3:34 pm

Hi RobinHood42, thanks very much for your helpful reply.
RobinHood42 wrote:...You would need to add a custom property to the activity stack...
Sorry, but I'm not familiar with how to do that. Where can I get more info on that?

Thanks again.

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

Re: Adding Variable Value to Custom Report Template

Post by RobinHood42 » Fri Apr 28, 2017 9:13 am

Hi Fergal,

I'm afraid that there is no further information available :lol:

Just use the aforementioned code within a recording module for example. That custom property will then be logged to the report:

Report.data file:
DataFile.png
DataFile.png (18.26 KiB) Viewed 653 times
Modify your XSL file to display the info within the header of the report:
XSLFile.png
XSLFile.png (13.06 KiB) Viewed 653 times
Which will finally look like the following, within the Rx report:
ReportFile.png
ReportFile.png (4.46 KiB) Viewed 653 times
Hope that helps.

Cheers,
Robin

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Adding Variable Value to Custom Report Template

Post by Fergal » Fri Apr 28, 2017 3:25 pm

Thanks ever so much Robin for taking the time to detail all of that, it worked perfectly to do what I needed :)