Forum Discussion

amit72avcg's avatar
amit72avcg
Occasional Contributor
14 years ago

How to specify a Timeout limit through scripts?



Hi,



Without using Project TestItems (Timeout) property, is there any other method through which we can run a particular routine for a specified time interval.

Is it possible to  specify a time limit through code?



I am using Utils.Timer property but getting a warning message. I am using TestComplete Version 6.



The code I am using is:



var test = Utils["Timers"]["Add"](20000, Unit1["abc"](), true);



The warning message is:


The unit that contains the timer procedure "" is not specified. 

No timer procedure specified. The timer will be disabled.




Is there any solution for this?



Thanks and Regards,

Amit

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    This is because the syntax of the add method is that the second parameter would be a string referencing the unit and procedure to be executed as the timer.



    Change your line of code to:



    var test = Utils["Timers"]["Add"](20000, "Unit1.abc", true);




    I'm not sure, though, if timers are what you want to use in this case, it depends somewhat on what's in method being called.  Timers are intended to execute a particular method at specified intervals.  In the code above, then, you'll execute the Unit1.abc routine once every 20 seconds.  This timer will run every twenty seconds no matter what test is being run or whatever until either the timer is disabled or it is deleted.



    The only other way that I know of to do what you want is to put particular time loops within your test routines (using "while" loops) to detect how long something is taking and, if it takes longer than a specified period of time, to exit out of the test.