Copying / Reusing Recordings for Very nasty repetitive task

Ranorex Spy, Recorder, and Studio.
jhance
Posts: 6
Joined: Fri Feb 27, 2009 11:48 pm

Copying / Reusing Recordings for Very nasty repetitive task

Post by jhance » Mon Jun 07, 2010 9:49 pm

Hi All -

I have a situation where I have 2 tasks to perform. The first is to set a system date (run -> cmd -> date 01/01/2010), and the second to click a button in my app's UI. The problem is that I have to do this 180 times (at least, once for each date).

What I envision is something like this:
Date_01_01_2010.Start()
Click_Button.Start()
Date_01_02_2010.Start()
Click_Button.Start()

Where Click_Button.rxrec is called over and over (single recording), but with unique date files as they have different dates for each iteration.

My question is - how might I do this most effective, hopefully without having to run the recorder 179 more times? My ideal solution would be to create the first recording, Date_01_01_2010.rxrec, then copy and paste it 179 times, making the very small changes needed to each one. This is still a lot better than recording each one from a blank recording, but still painful.

Any ideas on how I might accomplish this very unpleasant task?
Thanks so much, in advance!

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

Re: Copying / Reusing Recordings for Very nasty repetitive task

Post by Support Team » Tue Jun 08, 2010 8:51 am

Hi,
jhance wrote:My question is - how might I do this most effective, hopefully without having to run the recorder 179 more times?
Instead of record each date to its own recording, I would automate this by code. You have access to the whole framework of Ranorex and .Net. You can use a method like following:
private static List<System.DateTime> GetDateRange(System.DateTime startDate, System.DateTime endDate)
{
    if(startDate > endDate)
    {
        return null;
    }
    List<System.DateTime> dateList = new List<System.DateTime>();
    System.DateTime tmpDate = startDate;
    while(tmpDate <= endDate)
    {
        dateList.Add(tmpDate);
        tmpDate = tmpDate.AddDays(1);                    
    }
    return dateList;
}
And use this method in your main:
System.DateTime startDate = System.DateTime.Parse("01/01/2010");
System.DateTime endDate = System.DateTime.Parse("01/03/2010");

foreach(System.DateTime date in GetDateRange(startDate,endDate))
{
    //Execute your code actions
}
Regards,
Peter
Ranorex Support Team
.
Image