Sys.WaitProcess hanging intermittently
We have a script setup to run after each of our tests that shuts down any applications that might still be running. These are the tested applications but also other applications that may have been started during the test.
Mostly this works fine, but occasionally when we run the tests in TestExecute it will appear to just hang with the test indicating "Waiting on AppX". TestExecute doesn't move beyond this and the test run doesn't complete. What's more TestExecute refuses to shut down and we have to manually kill the TestExecute process or reboot the machine. This doesn't happen often and isn't reproducible, but we are now up to approx 60 tests in the test run and it is happening about a quarter of the test runs and therefore this is becoming a major issue for us. In most instances the app that it is waiting on is not even running.
Below is the code we are using to do this. Does anyone have any guidance on what we are doing wrong or how we can improve this?
function EventControl_OnStopTest(Sender)
{
Log.Enabled = false;
TestedApps.TerminateAll();
TerminateProcess("AppX");
TerminateProcess("AppY");
TerminateProcess("AppZ");
// Delete the settings files
aqFileSystem.DeleteFile(aqEnvironment.GetEnvironmentVariable("LocalAppData") + "\\MyAppData\\*.*");
Log.Enabled = true;
}
function TerminateProcess(processName){
var p = Sys.WaitProcess(processName, 0);
if (p.Exists){
p.Terminate();
}
}
Does the user or account holder which TestExecute is running on, have full admin permissions?