Page 2 of 2

Re: Calculate time between steps in a recording

Posted: Fri Apr 01, 2016 5:19 pm
by gowthamp
Can I add MODULE GROUP name while writing to text file?

I am using the following code to generate and load content to text file.

public System.DateTime startTime()
{
timeBefore = System.DateTime.Now;
Report.Info("Content Generation Started on "+timeBefore+".");
return timeBefore;
}

public void endTime()
{
System.DateTime timeAfter = System.DateTime.Now;
TimeSpan duration = timeAfter- timeBefore; //Time taken to generate content

string s = duration.Minutes.ToString()+" Minutes:"+duration.Seconds.ToString()+" Seconds."+duration.Milliseconds.ToString()+" Milliseconds"; //convert to minutes, seconds and milliseconds
Report.Log(ReportLevel.Info,"Time taken to Generate Content:"+ duration.Minutes.ToString()+" Minutes:"+duration.Seconds.ToString()+" Seconds."+duration.Milliseconds.ToString()+" Milliseconds");

System.IO.File.AppendAllText(@"C:\Users\###\Documents\test.txt","TestCase:"+TestCase.Current.Name+" -- Time taken to Generate Content: "+s+ Environment.NewLine); //Append test case name, time
}

I want to include MODULEGROUP name after test case while writing to text file.

I tried "string moduleGroup = TestSuiteModuleGroup.Current.Name;" but it is getting module name rather than MODULE GROUP name.

Re: Calculate time between steps in a recording

Posted: Mon Apr 04, 2016 7:36 am
by odklizec
Hi,

I believe you can obtain the name of current testmodulegroup by this code:

Code: Select all

Ranorex.Core.Reporting.TestReport.CurrentTestModuleGroupActivity.ModuleGroupName
PS: please next time, create a new topic instead of reopening an old and not completely related topic. Thanks! ;)

Re: Calculate time between steps in a recording

Posted: Mon Apr 04, 2016 2:41 pm
by gowthamp
Thanks odklizec, It helped and I am able to get moduleGroupName in text file.

This thread is related to time between steps, so I thought it is related to calculating time between module groups.