matthew_morgan
11 years agoOccasional Contributor
Unable to locate the iexplorer.exe process after closing
I wrote a method to close all open browsers before I start my tests (code below).
At the end of my test I have a step to type ~[F4] to close the browser. What seems to be happening is the alt-F4 doesn't actually close internet explorer. I mean it closes the user interface, but the process sticks around. The next time I run the test and the CloseBrowsers method gets called, the Sys.WaitProcess line gets stuck or hangs or freezes. Those terms aren't exactly accurate as I can still use everything on the system, but the execution will not continue and cannot be stopped without terminating the iexplorer.exe process myself.
I actually had 'FindAll' instead of WaitProcess at one point, but it did the same thing.
I want to continue to use alt-F4 to close the browser if possible rather than a close method (for reasons too boring to go in to here).
At the end of my test I have a step to type ~[F4] to close the browser. What seems to be happening is the alt-F4 doesn't actually close internet explorer. I mean it closes the user interface, but the process sticks around. The next time I run the test and the CloseBrowsers method gets called, the Sys.WaitProcess line gets stuck or hangs or freezes. Those terms aren't exactly accurate as I can still use everything on the system, but the execution will not continue and cannot be stopped without terminating the iexplorer.exe process myself.
I actually had 'FindAll' instead of WaitProcess at one point, but it did the same thing.
I want to continue to use alt-F4 to close the browser if possible rather than a close method (for reasons too boring to go in to here).
/**
* @readonly
* @enum {integer} Browser
*/
var Browser = {
Chrome: btChrome,
Firefox: btFirefox,
IExplore: btIExplorer,
Opera: btOpera,
Safari: btSafari
};
/**
* @summary Closes all open browsers
*/
CloseBrowsers = function ()
{
var resumeNext = false;
// Make linters happy
for (var browserName in Browser)
{
resumeNext = false;
while (!resumeNext)
{
var process = Sys.WaitProcess(browserName, 0, 1);
if (process.Exists)
{
process.Close(10000);
if (process.Exists)
{
process.Terminate();
aqUtils.Delay(500, "Terminating process...");
}
}
else
{
resumeNext = true;
}
}
}
};