In this post you will find an example of the function, which delays script execution and displays the time left for execution in the TestComplete Indicator.

Sometimes you need to postpone script execution. There is an excellent method BuiltIn.Delay() in TestComplete, which allows you to do this. When it works the message appears in the TestComplete indicator «Delaying script execution for XX milliseconds...».

However, if the delay is too long (for example, several minutes), you may want to know, how much time has left until the end of the delay.

Here is a simple function, which delays the execution and shows its progress in the Indicator window, as shown in the picture above.

function Sleep(iSeconds)
{
 i = iSeconds;
 while(i > 0)
 {
    BuiltIn.Delay(500);

    Indicator.PushText("Delaying script execution for " + iSeconds + " seconds. " + i + " seconds left");

    BuiltIn.Delay(500);
    i -= 1;
 }
 Indicator.Clear();
}

Please note that delay parameter is in seconds.

Besides, if you run this code in TestComplete 4, it may cause the Indicator to disappear from the screen. This problem doesn't reproduce in later versions of TestComplete.

You must be logged in in order to post comments