Page 1 of 1

any function to report current system time in Ranorex

Posted: Wed Aug 19, 2009 8:58 pm
by lingzhou
Hi, there,

Is there a function in Ranorex to report the current system timetamp?

Report.Info("There is a failure at", timestampfunction);

Re: any function to report current system time in Ranorex

Posted: Wed Aug 19, 2009 10:57 pm
by Ciege
You can write your own...

Code: Select all

            string strYear = System.DateTime.Now.Year.ToString();
            string strMonth = System.DateTime.Now.Month.ToString();
            string strDay = System.DateTime.Now.Day.ToString();
            string strHour = System.DateTime.Now.Hour.ToString();
            string strMinute = System.DateTime.Now.Minute.ToString();
            string strSecond = System.DateTime.Now.Second.ToString();
            string strDateTimeStamp = strYear + "_" + strMonth + "_" + strDay + "___" + strHour + "_" + strMinute + "_" + strSecond;

Re: any function to report current system time in Ranorex

Posted: Thu Aug 20, 2009 8:23 am
by Support Team
And it can get even easier, since the System.DateTime class already defines some nice overloads for the ToString() method, see http://msdn.microsoft.com/en-us/library ... tinfo.aspx
Report.Info("The current time is " + System.DateTime.Now.ToString("U"));
Moreover, the standard Ranorex XML and console loggers already print the time that the message was logged at.

Regards,
Alex
Ranorex Support Team

Re: any function to report current system time in Ranorex

Posted: Thu Aug 20, 2009 4:03 pm
by Ciege
You are correct about the "easier" way to do it. The reason I broke it out the way I did is so I can manipulate the different parts of the sate and time to name my report file in a standard fashion that was requested of me. Basically "Time_Date_logname.xml".

Re: any function to report current system time in Ranorex

Posted: Thu Aug 20, 2009 4:27 pm
by lingzhou
Alex, thanks for the link it is very helpful to manipulate the date/time format

Ceige, your function has better control of the format. By the way, how do you generate xml format report and how to control the content in that report?

Re: any function to report current system time in Ranorex

Posted: Thu Aug 20, 2009 4:36 pm
by Ciege
For the report, I use Report.Setup and pass it an XML name. That way when the report is created it is immediately viewable by anyone with the XSL available within IE.

I store my report XML & XSL in a networked directory so that others on my team (QA & Dev) have access to the reports.

The code below is what I use to create a report on the local drive that has a date/time stamped parent folder. Once the testing is complete I will move the folder to the network location that we have picked to store automation results.

Code: Select all

// Setup Reporter   
            string strYear = System.DateTime.Now.Year.ToString();
            string strMonth = System.DateTime.Now.Month.ToString();
            string strDay = System.DateTime.Now.Day.ToString();
            string strHour = System.DateTime.Now.Hour.ToString();
            string strMinute = System.DateTime.Now.Minute.ToString();
            string strSecond = System.DateTime.Now.Second.ToString();
            string strDateTimeStamp = strYear + "_" + strMonth + "_" + strDay + "___" + strHour + "_" + strMinute + "_" + strSecond;
            string LogFile = @"c:\temp\Report\" + strDateTimeStamp + @"\Package_Price_Quote_Reg_Test.xml";

            if (Directory.Exists(@"c:\temp\Report\" + strDateTimeStamp) == false)
            {
                Directory.CreateDirectory(@"c:\temp\Report\" + strDateTimeStamp);
            }

            Report.Setup(ReportLevel.Debug, LogFile, true);
            Report.SystemSummary();

Re: any function to report current system time in Ranorex

Posted: Fri Aug 21, 2009 3:32 pm
by lingzhou
Ceige, thank you so much for the code example. That works.

BTW, I benefit a lot from the functions you sent to me earlier, those are really good stuff!

Re: any function to report current system time in Ranorex

Posted: Fri Aug 21, 2009 3:53 pm
by Ciege
You are very welcome. Glad I could help.
Is there any functionality that you find missing in the Excel methods I sent you? I have only written methods for what I use but that is obviously not all that it can do.

Re: any function to report current system time in Ranorex

Posted: Fri Aug 21, 2009 4:15 pm
by lingzhou
I am mainly using two functions now. If I need more functions later on, I will try to change the code by myself and share it with you, or looking for help from you :D
Ciege wrote:You are very welcome. Glad I could help.
Is there any functionality that you find missing in the Excel methods I sent you? I have only written methods for what I use but that is obviously not all that it can do.