Ask a Question

Pro-Tip: Why wait?

Esteemed Contributor

Pro-Tip: Why wait?

The question has been asked recently "why wait for an object if I already know it doesn't exist?"


The answer: because you DON'T know. When it comes to onscreen objects, when you tell TestComplete to interact with the object, the first thing it has to do is determine if that object is present in memory.  You can't access ANY properties or methods or ANYTHING on that object if the object is not memory resident.

Here's kind of a mock up example that demonstrates this in JavaScript.  This is by no means as robust as the WaitAliasChild or WaitChild logic of TestComplete but it demonstrates, essentially, what is being done internally.  Basically, the child object of some object, we want to do something with it.  But we need to first make sure that it is actually an object of the correct object type before we can start interacting with it.


class myObject{
        this.Exists = true;
        this.someText = 'I think therefore I am';
        objectToCheck = eval('this.' + objectToCheck);
        if(!(objectToCheck instanceof myObject)){
            objectToCheck.Exists = false;
            return objectToCheck;
        else return objectToCheck;

var someObject = new myObject();

function testObject(){

    someObject.childObject = {};
    if (!someObject.waitMyObject('childObject').Exists){
        Log.Message('It does not think therefore it is not')
    else {


This is analogous to the WaitAliasChild methodology.  We KNOW we want to interact with a child object of one of our mapped Aliases.  But, before we do, we want to make sure that the referenced child object can be located in memory. So, we call the appropriate Wait method.  


Hope this helps explain this concept for some of you new users out there.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
SmartBear Alumni (Retired)

I like your detailed explanation, Robert!

Thanks a lot.

Tanya Yatskovskaya
SmartBear Community and Education Manager

Showing results for 
Search instead for 
Did you mean: