Forum Discussion

miller980's avatar
miller980
Regular Visitor
2 years ago

Auto Wait 3,000,000 ms needed

Hi,

 

I need auto wait not time out for around 40mins or so but the auto wait function is set to a 1,000,000 ms limit

 

I need a pop up box filling which could appear anytime from 1 to 45 mins 

2 Replies

  • KB1's avatar
    KB1
    Champion Level 2
    1. Declare a variable to track the elapsed time:

     

    var elapsedTime = 0;

     

    1. Use a while loop to continuously check for the popup box until it appears or the elapsed time exceeds 45 minutes (45 * 60 * 1000 = 2700000):

     

    while (elapsedTime < 2700000) {
    // Check for the popup box
    if (PopupBoxExists()) {
    // Popup box has appeared, break out of the loop
    break;
    }
    // Popup box has not appeared yet, delay for 1 minute (60 * 1000 = 60000)
    Delay(60000);
    elapsedTime += 60000;
    }

     

    1. After the loop, you can check if the popup box appeared or not. If it did, you can continue with your test logic. If it did not appear within the allotted time, you can add some code to handle the timeout as needed.

    Note: The PopupBoxExists() function should be replaced with your own code to check for the presence of the popup box. You can use various methods such as searching for specific UI elements or using TestComplete's built-in object recognition capabilities.



    This is what I've used

  • Kitt's avatar
    Kitt
    Regular Contributor

    I'm not entirely sure I follow, are you saying that you are running a bunch of tests and at some point during the test a random pop-up could appear which you need to account for? What is the pop-up and how is it triggered?

     

    Some options beyond relying on auto wait >> You can try using aqUtils.Delay and creating your own loop OR use HISUtils.StopWatch to create your own timer. See some samples below...

     

    This example stays in the loop while a certain page element property exists OR until 45 minutes has been reached (edit times as needed):

      var loopTimeout = 0;
      while (Aliases.Page.FindChild("WndCaption", "Retrieving*", 3).Exists) 
      {
        Delay(1000); // delay for 1 second
        loopTimeout++;
        if (loopTimeout == 2700000)  // If the loop has been going for 45 minutes get out of it.
        {
          Log.Error("Process exceeded the allotted time to retrieve data.");
          break;
        }
      }

     

    This example uses the StopWatch approach and is just setting a cap on the timer (45 min) where you can do other stuff in-between:

      // Time parameters
      stopWatch = HISUtils.StopWatch;
      limit = 2700000;// 45  minutes
      
      // Start time limit loop
      stopWatch.Start();
    
      if(stopWatch.Split() >= limit) {
        Log.Enabled == true;
        Log.Warning("The process has exceeded the " + (limit/1000)/60 + " minute time limit.");
        stopWatch.Stop();
        break;
      } 
      else {
        // do something else
      }    

    Change the logic to best suite your needs if you need to do other things while your delay/timer is running.