cancel
Showing results for 
Search instead for 
Did you mean: 

Killing IE after a test has run

Highlighted
Occasional Contributor

Killing IE after a test has run

I've created a series of automated tests using the click and record function of test complete. I've strung my tests together, and after each has run I've created another test 'IEKill', This is another click and record test which basically opens up command prompt and runs the following: taskkill /F /IM iexplore.exe /T

 

This is supposed to kill and close down all IE processes, but its not working. It'll run, but once the command has been issued, IE remains active. Note: I'm running my tests in a W10 environment, using IE11. 

 

I need a way of killing IE once my automated test has run. I'd assume that test complete focuses into the browser somehow which means when issuing a kill command it cant be killed off . 

 

Any help is appreciated. 

4 REPLIES 4
Community Hero

Re: Killing IE after a test has run

We call the following at the end of every IE test case.

function closeIEInstance() {
    var counter = 0;
    var browser;
    browser = Sys.WaitBrowser('iexplore', 1000);
    while((browser.Exists) && (counter < 60)){
        counter++;
        browser.Terminate();
        browser = Sys.WaitBrowser('iexplore', 1000);
    }  
} 

Robert Martin
[Community Expert Group]
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
Extensions available
Occasional Contributor

Re: Killing IE after a test has run

How would i go about implementing that command? Bearing in mind i'm keyword testing, not writing the tests myself.

 

Community Hero

Re: Killing IE after a test has run

1) Create a script unit

2) Add that code to the script unit

3) call "Run Script Routine" operation within your keyword test to run that code.


Robert Martin
[Community Expert Group]
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
Extensions available
Community Hero

Re: Killing IE after a test has run

Hi,

 

Here is our implementation in python:

 

def kill_redundant_browser_process(process_name):
    Sys.Refresh()
    if Sys.WaitProcess('{}'.format(process_name), 1000).Exists:
        Sys.Browser(process_name).Close()
        Sys.Refresh()
        if Sys.WaitProcess('{}'.format(process_name)).Exists:
           Sys.WaitProcess('{}'.format(process_name)).Terminate()
        Log.Message("The redundant '{}' process was killed".format(process_name))