Ask a Question

How to Terminate Two or more instance of Application

ramaraja
New Contributor

How to Terminate Two or more instance of Application

 

I have teste my wpf application using testcomplete. if already two instance of application are opened means how to i terminate that all application and i need to continue sequence of other cases to be run..

 

Note: i already tried TestedApps.<<app>>.Terminate();(when 2 instance of tested application are in open) but it vain.

 

 

Kindly advise me.

2 REPLIES 2
tristaanogre
Esteemed Contributor

If your application process name in Windows is myApp, then try the following:

 

function closeApplicationInstances(){
    var currentProcess = Sys.WaitProcess('myApp', 2000);
    while (currentProcess.Exists){
        currentProcess.Terminate()
        currentProcess = Sys.WaitProcess('myApp', 2000);
    }
}

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

I wouldn't bother checking for 2 instances.  At the top of your code, before you start the actual test, use @tristaanogre's code and close everything, then open your one instance for testing.  

cancel
Showing results for 
Search instead for 
Did you mean: