Code: Select all
Report.Info("Old Report format!");
Code: Select all
Report.Info("Old Report format!");
// Get Starting Time System.DateTime timestamp = Ranorex.Core.Reporting.ActivityStack.Current.BeginTime;Now, run through all test cases in ActivityStack, calculate the starting time of each test case and add it as a the custom field:
// Iterate through all test cases, calculate starting time and add a custom field Ranorex.Core.Reporting.ActivityStack.Instance.VisitAll(a => { if(a.GetType().Name=="TestCaseActivity") { System.DateTime startTime = System.DateTime.Now - (a as Activity).ElapsedTime; Report.Info (string.Format ("Started: {0:H:mm:ss}",startTime )); (a as Activity).CustomProperties.Add("CustomFieldStartingTime", string.Format ("Started: {0:H:mm:ss}",startTime )); } return true; });Note: (Added on May 9,2014): If you additionally want to have the starting time next to each iteration of a loop, simply enhance the conditional statement and use the following one:
if (a.GetType().Name=="TestCaseActivity" || a.GetType().Name=="TestIterationActivity") ...Important: Don't forget to update the ActivityStack:
Ranorex.Core.Reporting.ActivityStack.Update();
<span class="duration"><xsl:value-of select="./@duration"/></span>with
<span class="duration"><xsl:value-of select=".//@CustomFieldStartingTime"/></span>Updated 2014/05/05: closing span-tag has been added in the second line (Roland E)
<xsl:value-of select="./@duration"/>and use
<xsl:value-of select=".//@CustomFieldStartingTime"/>instead.
Code: Select all
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
// Read out Starting Time from XML Document
Ranorex.Core.FastXml.XmlDoc xmlDoc = new Ranorex.Core.FastXml.XmlDoc("dummyRoot", false);
Ranorex.Core.FastXml.XmlNode xmlNode = Ranorex.Core.Reporting.ActivityStack.Instance.RootActivity.ToXmlNode(xmlDoc);
string sTimestamp = xmlNode["timestamp"];
System.DateTime timestamp = Convert.ToDateTime (sTimestamp);
// Iterate through all test cases, calculate starting time and add custom field
Ranorex.Core.Reporting.ActivityStack.Instance.VisitAll(a =>
{
if(a.GetType().Name=="TestCaseActivity")
{
System.DateTime startTime = System.DateTime.Now - (a as Activity).ElapsedTime;
Report.Info (string.Format ("Started: {0:H:mm:ss}",startTime ));
(a as Activity).CustomProperties.Add("CustomFieldStartingTime", string.Format ("Started: {0:H:mm:ss}",startTime ));
}
return true;
});
Ranorex.Core.Reporting.ActivityStack.Update();
}
Thanks for your quick answer, I'm looking forward on version 5.4.odklizec wrote:Hi Thomas,
This complicated workaround should soon become obsolete. Ranorex 5.4 should have an option to use time stamps instead of duration in reports. See this post... http://www.ranorex.com/forum/been-askin ... tml#p32853