How to Validate Time Gaps : Automation API

How to Validate Time Gaps

Class library usage, coding and language questions.

How to Validate Time Gaps

Postby martinsw » Mon Dec 12, 2011 3:28 pm

Hi,

My SUT has a diary page which can either be in 30 minute mode or 1 hour mode. When in 30 minute mode there is a gap of 30 mins between each of the TRs in the table body. See below:

TR1 12am
TR2 (no innertext)
TR3 1am
TR4 (no innertext)
TR5 2am
etc...etc...

When the diary is in 1 hour mode there is a gap of 1 hour between each TR, see below:

TR1 12am
TR2 (no innertext)
TR3 2am
TR4 (no innertext)
TR5 4am
etc...etc...

What I need to do is set up a test that will validate that the diary is in 1 hour mode when the user selects that this should be the case. This would be an easy test to create if the starting point of the diary was always 12AM (in such a case I would just validate that TR3 equals 2am, or that TR5 equals 4am) but it won't be. The start time will be dependent on the start time of the user's first appointment (i.e. it will change all the time). Hence, what I need to check is that the innertext value of TR3 is 2 hours more than the innertext value in TR1. But the inner text of TR1 will not be known until runtime. Is there a way I can do this? If not, can you suggest another means by which I can test this scenario?

Thanks in advance.

Martin
Attachments
Diary.rxsnp
(188.51 KiB) Downloaded 7 times
martinsw
 
Posts: 41
Joined: Fri Dec 09, 2011 3:48 pm

Re: How to Validate Time Gaps

Postby sdaly » Mon Dec 12, 2011 4:39 pm

How about something like this -


Code: Select all
Validate.IsTrue(GetInterval() == 1, "Validating diary is in 1 hour mode.");

      public static int GetInterval(){
         IList<DivTag> times = Host.Local.Find<DivTag>("/dom//div//th//div[@innertext!='all day']");
         
         int diff = 0;
         if(times.Count > 2){
            int time1 = int.Parse(times[0].InnerText);
            int time2 = int.Parse(times[1].InnerText);
            diff = time2 - time1;
         }
         
         return diff;
      }
User avatar
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: How to Validate Time Gaps

Postby martinsw » Mon Dec 12, 2011 6:02 pm

Thanks for the response.

I should have said, is there anyway to create this diary test soley through the use of the Ranorex GUI tools rather than having to write a piece of user code? I want to try and avoid manipulating user code if at all possible.

Thanks!

Martin
martinsw
 
Posts: 41
Joined: Fri Dec 09, 2011 3:48 pm

Re: How to Validate Time Gaps

Postby sdaly » Tue Dec 13, 2011 10:15 am

It is possible - you would prob have to restore your DB to a known state in your global set up then use a known user where you know what their start time is. If you want to do any clever dynamic things, you are going to have to learn a bit of programming imo....that is automation!
User avatar
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: How to Validate Time Gaps

Postby martinsw » Thu Dec 15, 2011 11:33 am

OK Many thanks! :D
martinsw
 
Posts: 41
Joined: Fri Dec 09, 2011 3:48 pm


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests