Forum Discussion

TestCoeUs1337's avatar
TestCoeUs1337
Occasional Contributor
6 months ago

How to speed up checking for non-existence of objects in TestComplete?

I'm running into an issue where asserting that an object does NOT exist is taking an unexpectedly long time (~10 seconds) in my TestComplete tests. I've tried using both:

if(!Aliases.restOftheCode.exists)

and

aqObject.CheckProperty("Exists", False)

But they both take around 10.25 seconds to execute.

I suspect this has to do with some global timeout setting, but I'm not sure exactly which one. Is there a way to override this timeout for just a single test case or step, rather than changing it globally for the entire project?

My goal is to make these "object does not exist" checks run much faster, ideally just taking a fraction of a second. Any tips on the optimal way to achieve this would be greatly appreciated!


    • TestCoeUs1337's avatar
      TestCoeUs1337
      Occasional Contributor

      I don't need to wait for the property to exist after deletion; my goal is to assert that it doesn't exist anymore. How can I achieve this without adjusting the auto-wait timeout, but instead using a method tailored for this particular situation?

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        WaitNNN methods are used to wait for an object in test, which is different from property. You can specify a timeout period of 0 seconds, and it will return the needed object if it exists. Otherwise it will return a stub. To check whether the returned object is a valid object, use the Exists property.

        I suggest you try the examples given in the link that I have provided, on the control you are working on. 

  • PhilippeS's avatar
    PhilippeS
    New Contributor

    I got round this problem by using the "WaitAliasChild" method.

    (There is a optional waitTime as parameter)
    Check the documentation : https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/waitaliaschild-method.html

      if(Aliases.yourAliasesName.WaitAliasChild("yourElement").Exists){
        doSomething();       
      }

    Regards

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

      PhilippeS wrote:

      if(Aliases.yourAliasesName.WaitAliasChild("yourElement").Exists){
          doSomething();       
        }

      [Just as a side note]

      Yes, this might work, but the same condition as mentioned in my previous answer applies: Aliases.yourAliasesName object (and all objects within physical objects' hierarchy that precede "yourElement" aliased object) must exist. Otherwise TestComplete will start to search for them before been able to execute the .WaitAliasChild() call.

       

  • eykxas's avatar
    eykxas
    Regular Contributor

    Hi! In my case, all wait methods (waitAlias, waitNNN etc...) doesn't have the behavior that I'm looking for.

    So instead, I set the autowait timeout directly in my script code, then revert it to the default value I'm using.

    for example :

    Options.Run.Timeout = 50; //50ms

    if(!myElement.Exists){
    doSomething();
    }

    Options.Run.Timeout = 4000; //4s

    So TestComplete look for the object only for 50ms (nearly instant).