Forum Discussion

iamraj09's avatar
iamraj09
Contributor
11 years ago

Unable to make the process wait till Window is closed

Hi,



My name is Guru. I have recently started to work on Test Complete. I am trying to make the instructions to wait till a specific window is closed.



The following is the part of the code where I got stuck. Please guide me through.Thanks in advance.




StopWatch = HISUtils["StopWatch"];


Central = Sys.Process("Central");


// ref for the device list ....


Status_Bar=Sys.Process("Central").WinFormsObject("MainForm").WinFormsObject("_statusBar");


Delay(1000);


DeviceSpace=Sys.Process("Central").WinFormsObject("MainForm").WinFormsObject("DockContainer", "", 2).WinFormsObject("Devices").WinFormsObject("Devices").WinFormsObject("_treeTableView").WinFormsObject("InternalListView", "");


 


DeviceSpace.ClickItem("MyController (TM241CEC24T/U)                                                                          ", 0);


DeviceSpace.Keys("[Down][Down]");


DeviceSpace.ClickItemR("Application                                                                          ", 0);


 


//DeviceSpace.ClickItemR("Application                                                                          ", 0);


Delay(800);


DeviceSpace.Keys("[Down][Down][Down][Down][Down][Down]");


DeviceSpace.Keys("[Enter]");


 


StopWatch["Start"]();


Sys.Process("Central").WaitWindow("*","Add Function From Template",-1,1000000);

 


Add_Template_Window=Sys.Process("Central").WinFormsObject("FunctionTemplateInstantiationDialog");  //  this is the window for which I have to wait to close 


 


StopWatch.Stop();


Time=StopWatch.ToString();


Excel_Launch = Sys["OleObject"]("Excel.Application");


Excel_Launch["Visible"]=true;  


Book=Excel_Launch.Sheets("Tabelle1");


  


Excel_Launch.DisplayAlerts=false;


 


Book.Cells(10,1)="Time taken for ADD_Template_Window to PopUP is ";


Book.Cells(10,2)= Time;


Book["SaveAs"]("Worksheet");


Time="";


  


Delay(1000);


 


Enter_Template_Name=Sys.Process("Central").WinFormsObject("FunctionTemplateInstantiationDialog").WinFormsObject("textBoxFunctionName");


Enter_Template_Name.SetText("ATV32_Node01");  // Entering the Template name ...


 


 


Browse_Template=Sys.Process("Central").WinFormsObject("FunctionTemplateInstantiationDialog").WinFormsObject("buttonSelectTemplate");


Browse_Template["Click"]();


 


Select_Template=Sys.Process("Central").WinFormsObject("SelectionDialog").WinFormsObject("SelectionControl", "").WinFormsObject("TreeTableView").WinFormsObject("InternalListView", "");


Select_Template.ClickItem("ATV32_CANopen                                                                          ", 0);


Add_Template_Button=Sys.Process("Central").WinFormsObject("SelectionDialog").WinFormsObject("buttonOK");


 


Add_Template_Button.ClickButton();


Enter_Template_Name.Click();


 


//var Template_address_area=Sys.Process("Central").WinFormsObject("FunctionTemplateInstantiationDialog").WinFormsObject("gridViewDevices");


 


var Template_OK=Sys.Process("Central").WinFormsObject("FunctionTemplateInstantiationDialog").WinFormsObject("buttonOK");


Template_OK.ClickButton();


 


StopWatch["Start"]();

 


while(Add_Template_Window.Exists==true){    // this is the loop  that  I have tried ..


while(!Template_OK.Enabled)


{


Delay(800);


break;


}


}


 


StopWatch["Stop"]();


Time=StopWatch["ToString"]();  


StopWatch["Reset"]();


  


Book.Cells(11,1)="Time taken for adding ATV32_Node01 is ";


Book.Cells(11,2)= Time;


Book["SaveAs"]("Worksheet");



Best Regard

Guru 

3 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor


    //This should be sufficient to pause script execution until the window is closed


    while(Add_Template_Window.Exists){


      Delay(1000, "Waiting for window to close...");


    }


  • Thank you for your respone.



    I have tried the same before but it wont work.....I dont know why.  
  • This is what we use for browsers. Pehaps you can tweak for your issue




    function  closeBrowser()


    {


     


      while (Sys.WaitBrowser().Exists)


      Sys.WaitBrowser().Close();


     


    }