Forum Discussion

mjohnsen's avatar
mjohnsen
New Contributor
13 years ago

Delay TC script until application finishes loading big file

I need my TC script to wait until my application has completed loading a big file (takes > 1hr). Is there an easy, safe way to do this?



I have tried the following combination of code, as none of them fully wait for the application to be responsive:

(The 2 sec delays are there because I have seen MyApp become briefly responsive at times and I want the process to go back to hanging before I start detecting it.)


 


aqUtils.Delay(2000, "Delays the script execution for 2 secs.");   

 


 var p1 = Sys.Process(SystemDefaults.processName); 


 var dotNetProcess = dotNET.System_Diagnostics.Process.GetProcessById_2(p1.ProcessID); 


 

while(!dotNetProcess.Responding)  




        aqUtils.Delay(10000, "Delays the script execution for 10 secs while waiting for MyApp."); 




    


aqUtils.Delay(2000, "Delays the script execution for 2 secs..");


    

var mainFrame = null;


while (mainFrame === null) {


        mainFrame = <MyApp>.WinForms.FindDialog("ClrMainFrame", 2);          


}





Help is much appreciated!!:-)

  • sastowe's avatar
    sastowe
    Super Contributor
    Does your app have a  visual, on screen mechanism for determining completion? I have a similar situation in which the application has a button that is disdabled. I loop and delay until the button is enabled. Is that something you could do?
  • mjohnsen's avatar
    mjohnsen
    New Contributor


    I have added code to wait for the menu bar to be active. My application hangs until the loading is completed, so this works ok, but  not fully. In short "blinks", my application will be active even though it is still loading, and go back to hanging. I have to repeat this code: 



    while
    (menuBar === null) {



    menuBar = <myFwk>.CreateMenuBar();



    }



    There is a risk that this will not work, it is not a an elegant way of dealing with the issue. I am surprised TestComplete is not able to handle this in a safe way...