Page 1 of 1
Adding Variable Value to Custom Report Template
Posted: Wed Apr 26, 2017 11:07 am
by Fergal
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:
What code can be added to the custom report, to add the value of the versionNumber variable?
Thanks!
Re: Adding Variable Value to Custom Report Template
Posted: Thu Apr 27, 2017 11:21 am
by RobinHood42
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
Re: Adding Variable Value to Custom Report Template
Posted: Thu Apr 27, 2017 3:34 pm
by Fergal
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.
Re: Adding Variable Value to Custom Report Template
Posted: Fri Apr 28, 2017 9:13 am
by RobinHood42
Hi Fergal,
I'm afraid that there is no further information available
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
Modify your XSL file to display the info within the header of the report:
XSLFile.png
Which will finally look like the following, within the Rx report:
ReportFile.png
Hope that helps.
Cheers,
Robin
Re: Adding Variable Value to Custom Report Template
Posted: Fri Apr 28, 2017 3:25 pm
by Fergal
Thanks ever so much Robin for taking the time to detail all of that, it worked perfectly to do what I needed