any function to report current system time in Ranorex

Ask general questions here.
lingzhou
Posts: 21
Joined: Fri Jul 10, 2009 7:49 pm

any function to report current system time in Ranorex

Post by lingzhou » Wed Aug 19, 2009 8:58 pm

Hi, there,

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

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: any function to report current system time in Ranorex

Post by Ciege » Wed Aug 19, 2009 10:57 pm

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;
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: any function to report current system time in Ranorex

Post by Support Team » Thu Aug 20, 2009 8:23 am

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
.
Image

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: any function to report current system time in Ranorex

Post by Ciege » Thu Aug 20, 2009 4:03 pm

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".
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

lingzhou
Posts: 21
Joined: Fri Jul 10, 2009 7:49 pm

Re: any function to report current system time in Ranorex

Post by lingzhou » Thu Aug 20, 2009 4:27 pm

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?

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: any function to report current system time in Ranorex

Post by Ciege » Thu Aug 20, 2009 4:36 pm

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();
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

lingzhou
Posts: 21
Joined: Fri Jul 10, 2009 7:49 pm

Re: any function to report current system time in Ranorex

Post by lingzhou » Fri Aug 21, 2009 3:32 pm

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!
Last edited by lingzhou on Fri Aug 21, 2009 7:20 pm, edited 1 time in total.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: any function to report current system time in Ranorex

Post by Ciege » Fri Aug 21, 2009 3:53 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

lingzhou
Posts: 21
Joined: Fri Jul 10, 2009 7:49 pm

Re: any function to report current system time in Ranorex

Post by lingzhou » Fri Aug 21, 2009 4:15 pm

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.