Forum Discussion

bgran05's avatar
bgran05
Occasional Contributor
7 years ago

How to use WaitChild or WaitAliasChild when object name contains "Alias" already?

I am using jscript for TestComplete scripts and am struggling to figure out how to write a custom wait condition that will take an object as input and wait a specific number of seconds. I have obj...
  • tristaanogre's avatar
    7 years ago

    Instead of passing in the object itself, you should pass in two parameters... the parent object of the object you want to wait for, and the string name of the child object.

     

    So, here's your code:

     

    function WaitForConfigObjectExist(parentObject, objectName, maxWaitTime)
    {
      var stopWatch = HISUtils.StopWatch; 
      stopWatch.Start();
    
      while(!parentObject.WaitChild(objectName, 500).Exists)
      { 
        Delay(500);
        var currentTime = stopWatch.Split();
        if(currentTime > maxWaitTime)
        {
          Log.Warning(objectName + " not found after  " + maxWaitTime + " seconds.");
          return false;
        }
    }

    And you'd call it like this

     

    WaitForConfigObjectExists(Aliases.Parent.Tab1, 'button', 10000)