Forum Discussion

mfoster711's avatar
mfoster711
Regular Contributor
1 hour ago

aqUtils.Delay() vs Delay()

I have upgraded to TC 15.80 with python. I have encountered one  issue that puzzles me.

Historically, in our scripts, we have used Delay(time in millsecs) when needing to have a hard pause in our script. We did NOT use aqUtils.Delay(##), just plain Delay(##). This has always worked.

Delay(1000)  # we used this to pause for 1 second

aqUtils.Delay(1000)  # we did not use this

Now I am getting error "name 'Delay' is not defined" since upgrading to TC 15.80. If I add import Sys or import aqUtils then the Delay starts working again, even though I did not change the Delay call to aqUtils.Delay(##). 

from tc import Sys
from tc import aqUtils

def main():
    Delay(1000)  # this works if I add either of the above imports

    aqUtils.Delay(1000)    # regardless, should I be using this with import aqUtils?

So, what is proper? Should I have been using aqUtils.Delay(##) all of these years?

2 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Delay() is a built-in global routine, and aqUtils.Delay() belongs to the aqUtils utility object. Both do the same thing. For Python 3.12 and onwards, it now treats each global as a regular scoped object

    In JavaScript, I always use aqUtils.Delay(), for no particular reason!

  • mfoster711's avatar
    mfoster711
    Regular Contributor

    I just found this that answers the question.

    Specifics of Usage Common for All Languages | TestComplete Documentation

    You can skip the object name when calling methods of some program objects in scripts. This feature is supported by the aqConvertaqEnvironmentaqObjectaqUtilsBuiltInUtilities and Win32API objects. For example, you can call the Delay method of the aqUtils object as aqUtils.Delay(…) or as simply Delay(…).

    With all of the python changes, I think it is probably safer to switch all of my Delay() to aqUtils.Delay() to be clear what they are.

    Thanks for you reply