WaitForExist()

Ranorex Studio, Spy, Recorder, and Driver.
cruzez
Posts: 24
Joined: Thu Jan 27, 2011 3:03 am
Location: London, UK

WaitForExist()

Post by cruzez » Thu Jul 24, 2014 5:38 pm

Hi,
I have used WaitForExist/NotExist() function quite extensively across my test automation.

Is there any easy way to record time it took start waiting for an element appear or disappear until element successfully finishes waiting for exist/notexist?

Code looks like this:

private Duration WaitTimeOut(string seconds)
{
double secs = double.Parse(seconds);
return TimeSpan.FromSeconds(secs);

}

repo.PaymentSenseLTDHomeArea.KOverlayInfo.WaitForNotExists(WaitTimeOut(PageTimeout));

And I am passing wait time (PageTimeout) from dataSource connection, so that I can control waiting globally across all tests.

Now I am thinking it would be nice to log actual time it took in waiting. Is there is any simplest way to do it without adding too much code?

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: WaitForExist()

Post by krstcs » Thu Jul 24, 2014 6:48 pm

You could wrap the WaitForExist/NotExist() call with two data-time stamps and subtract the first from the second. It will be a little rough, but should do the trick.

Code: Select all

System.DateTime start = System.DateTime.Now;
//do stuff here
TimeSpan waitTime = System.DateTime.Now.Subtract(start);
Shortcuts usually aren't...

cruzez
Posts: 24
Joined: Thu Jan 27, 2011 3:03 am
Location: London, UK

Re: WaitForExist()

Post by cruzez » Fri Jul 25, 2014 5:42 pm

Thanks,
simple3 line code works brilliant :)

I was stupid made it complicated adding a function wait sleep while time etc,,,,

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: WaitForExist()

Post by krstcs » Fri Jul 25, 2014 6:06 pm

Hehe, I find myself making things more complicated than I should way more often than I like. :D

You're welcome!
Shortcuts usually aren't...