cancel
Showing results for 
Search instead for 
Did you mean: 

How to add the following to my Project Suite?

Highlighted
Contributor

How to add the following to my Project Suite?

I'm new to TestComplete and fairly new to scripting in general. I could use assistance in adding the following script to my Project Suite via a Keyword Test or if not a Keyword Test a standard script to be called. The issue to resolve is if an 'iexplore.exe' process is running it needs to be terminated prior to launching a new instance of IE.

 

The below script is found in this post: https://community.smartbear.com/t5/TestComplete-Functional-Web/Cannot-obtain-the-window-with-the-win...

 

 

//To run this function : i.e  fn_closeProcess("iexplore")

 

function fn_closeProcess(str_ProcessName)
{
      var arr_Processes = null;
     
      if(str_ProcessName != "")
      {
            arr_Processes = Sys.FindAllChildren("ProcessName",str_ProcessName);
           
            if(arr_Processes != null)
            {
                  for(var b = 0 ; b < arr_Processes.length ; b++)
                  {
                        arr_Processes[b].Close();
                  }
            }
           
            //if any missed process will finish off here
            var b_Object = Sys.WaitProcess(str_ProcessName, 1000);
           
            while(b_Object.Exists)
            {
                b_Object.Terminate();
                Log.Message("We have tried mutliple times to close the process [" + str_ProcessName + "] hence terminating the process.");
            }
           
            var chkObj = Sys.FindChild("ProcessName",str_ProcessName);
           
            if(!chkObj.Exists)
            {
                  return true;    
            }
            else
            {
                  Log.Message("We have tried terminating the process [" + str_ProcessName + "] but no luck. Need to have a LOOK!");
                  return false;
            }
      } 
      return false;
}

 

 

Thank you in advance for your assistance.

 

2 REPLIES 2
Contributor

Re: How to add the following to my Project Suite?

Should I utilize the Process Action Operation?

http://support.smartbear.com/testcomplete/docs/keyword-testing/reference/test-actions/process-action...

 

I've used the Process Action Operation to search for and terminate any existing iexplore.exe processes. That works, but it doesn't seem as universal as the script in my original above.

Community Hero

Re: How to add the following to my Project Suite?

I think @tristaanogre's script in the first post you found would be easier for you to use:

 

browser = Sys.WaitProcess('iexplore', 1000);
            while((browser.Exists)){
                browser.Terminate();
                browser = Sys.WaitProcess('iexplore', 1000);

 

New Here?
Join us and watch the welcome video:
Watch the New Interview
APITestingMistake#2
Top Kudoed Authors