Forum Discussion

matt_vb's avatar
matt_vb
Occasional Contributor
2 years ago
Solved

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?

4 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3
    When it hangs up, what items are left in TaskManager?
    • matt_vb's avatar
      matt_vb
      Occasional Contributor

      The application it says it is waiting on is not running and not shown in TaskManager.

      The TestExecute runner is still showing (see image), but it is not responsive. Clicking on it does nothing. Sometimes TestExecute will show as running in TaskManager and sometimes it doesn't. If it is showing in TaskManager then we can kill the TestExecute task, but if it isn't showing then we have to reset the computer to get it back to a working state.

      In this example the application it is waiting on (ExerciseBuilder) was not used in the test and the only place it was referenced was as a process being terminated in the OnStopTest handler.

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Tough one when it's not reproducible, but here's what I would try

     

    1) Add a little time to the WaitProcess. Rather than 0, maybe 2000.

    2) Add an else clause to your if-exists, with just a log message: processName does not exist

     

    Let's see if this either fixes it or gives us some more information to work on.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Does the user or account holder which TestExecute is running on, have full admin permissions?