How to add a delay to a validation step

Best practices, code snippets for common functionality, examples, and guidelines.
bygones
Posts: 31
Joined: Fri Nov 27, 2015 11:32 am

How to add a delay to a validation step

Post by bygones » Fri Nov 27, 2015 11:34 am

Hi,

I have a validation step that I like to delay a bit as the action before needs time to execute. So the element I need to verify on is already there, but the text changes after a short delay, and the new text is the one I like to verify.

Is it possible (without code) to delay a validation step (or any step in general) ? I'm not looking for an general delay time for all steps, but for individual steps.

Thanks

bygones
Posts: 31
Joined: Fri Nov 27, 2015 11:32 am

Re: How to add a delay to a validation step

Post by bygones » Mon Nov 30, 2015 8:45 am

found it myself right after hitting the submit button here.

There is the dedicated "Delay" action that does this job

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to add a delay to a validation step

Post by odklizec » Mon Nov 30, 2015 9:25 am

Hi,

I would suggest you to explore WaitForExists|NotExists action(code). Delay (no matter how long) could easily finish before the application is ready for next step. Additionally, adding too many hardcoded delays would make your tests (unnecessary) slower. WaitFor waits until the appearance/disappearance of an item (with timeout option). Hence WaitFor action is much better way of handling delays in tests.
Last edited by odklizec on Mon Nov 30, 2015 12:32 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

bygones
Posts: 31
Joined: Fri Nov 27, 2015 11:32 am

Re: How to add a delay to a validation step

Post by bygones » Mon Nov 30, 2015 10:40 am

Thanks Pavel,

I didn't see the "WaitFor" action. I will use this and see whether this solves my delay problem

User avatar
jasoncleo
Posts: 37
Joined: Mon Jun 08, 2015 7:37 am

Re: How to add a delay to a validation step

Post by jasoncleo » Wed Dec 16, 2015 4:23 am

I agree with Pavel that fixed delays are to be avoided wherever possible. A simple test can blow out to be very long with fixed delays as you'll end up coding your test to run with the delays set for the 'worst case scenario" (i.e. when the server is slow, the app is under load, or the VM is just running like a dog).

If there is a UI element that gives you a clear indication of when the screen has refreshed, then you can do a WaitForExists()/WaitForNotExists().

Alternatively, if the screen doesn't really change, but the content or attribute of an element is expected to change, then you could write a method that polls that UI element until the content/attribute changes to what you expect, or the timeout occurs.

If the expected content attribute is found, the loop ends early and you return with a success, otherwise if the timeout occurs, you fail or throw an exception.

When we applied this to some of our early Ranorex tests, we were seeing an average of 30% reduction in execution times, so its worthwhile doing.