Forum Discussion

CHolman's avatar
CHolman
Occasional Contributor
7 years ago

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

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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);
        }  
    } 
    • CHolman's avatar
      CHolman
      Occasional Contributor

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

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        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.