Forum Discussion

tristaanogre's avatar
tristaanogre
Esteemed Contributor
9 years ago

IndicatorTimer Script Extension

shankar_r requested a feature addition to TestComplete recently.  You can find his feature request at the following link.

 

https://community.smartbear.com/t5/TestComplete-Feature-Requests/Indicator-Timer/idi-p/131680

 

While I think that this should be something added by default to TestComplete as, perhaps, an option in the Playback project property, in the meantime, I've put together a script extension that will do this in a slightly limited fashion.  You can find the extension at  

https://bitbucket.org/privateteamogre/scriptextensions/downloads/IndicatorTimer.tcx

 

Here's the description of how to implement it from the feature request:

Basically, the implementation is like so...

First, in your project, create a simple wrapper function somewhere to call the timer object method.  The reason being is that timer objects cannot call script extension methods directly.  Something like this:

function timerExecution() {
    IndicatorTimer.updateIndicatorTimer();
}



 

Next, at the beginning of your project, make the following call:

 

 

    IndicatorTimer.projectStartTime = aqDateTime.Now();

This initializes the timer at the start of your project run so we can get the elapsed time.

Then, create your timer:

    myTimer = Utils.Timers.Add(1000, 'Unit1.timerExecution', true);

And boom... there ya go... every second now, the Indicator will update to include a formatted text showing hours, minutes, and seconds of elapsed time.

You can even include at the end of your project a line like:

Log.Message('Overall elapsed time = ' + aqConvert.DateTimeToFormatStr(IndicatorTimer.projectElapsedTime, '[%H:%M:%S]'));

One caveat that I haven't found a work around for...

The indicator gets updated a LOT during a test run... especially with "WaitNNN" calls and the like.  Anytime the indicator gets updated like that, it blows away the time text in the indicator... however, all you have to do is wait a second or so and it will show up again.  You could also decrease the timer interval from 1000 to 100... every 10th of a second then we'll update the indicator.  This seems to do pretty well but I'm not sure about performance overhead.