Forum Discussion
North-E
16 years agoOccasional Contributor
Forgive me for posting twice. But I have the next problem...
I successfully cought exceptions caused by application's crash. Here this the code sample where I try to terminate process (if necessary) and stop test item run.
function IsProcessExist()
{
var ProcessName = Project.Variables.ProcessName;
Log.Message("Checking process existance");
var ProcessExistance = Sys.WaitProcess(ProcessName, 0).Exists;
Log.Message("Process existance is checked");
return ProcessExistance;
}
function Terminate(Exception)
{
var ErrorMessage = new String();
if (arguments.length == 0)
var ErrorMessage = "Unknown error or exception";
else
{
if (typeof(Exception) == "object")
ErrorMessage = Exception.description;
else
ErrorMessage = Exception;
}
var ProcessName = Project.Variables.ProcessName;
var TerminationTimeOut = Project.Variables.TerminationTimeOut * 1000; // in milliseconds
Log.Error("Termination reason: " + ErrorMessage);
/* Checking application's process for existance */
if (!IsProcessExist())
{
Log.Message("Application's process is already terminated");
}
else
{
Log.Message("Attempt to terminate process...");
TestedApps.ScanMagic.Terminate(); // sending instructions to terminate process
}
aqUtils.Delay(TerminationTimeOut);
Log.Message("Stopping test case execution...");
Runner.Stop(true); // stopping current test only
}
This one works fine in most cases but sometimes application crashes with "Microsoft Visual C++ Runtime Library Error" window. According to received logs the application's process is already terminated but any actions, for example, aqUtils.Delay(...) or Runner.Stop(true) can't be performed before I activate any other application or press Windows' "Start" button manually. Only after this script continue it's work and stops.
I tried to simulate "Start" button pressing, and received click events in my log...but in real nothing has changed - application's window and modal error window described higher are still preventing normal script execution...
What's the reason? Can I solve this problem by any methods?
Thanks...
I successfully cought exceptions caused by application's crash. Here this the code sample where I try to terminate process (if necessary) and stop test item run.
function IsProcessExist()
{
var ProcessName = Project.Variables.ProcessName;
Log.Message("Checking process existance");
var ProcessExistance = Sys.WaitProcess(ProcessName, 0).Exists;
Log.Message("Process existance is checked");
return ProcessExistance;
}
function Terminate(Exception)
{
var ErrorMessage = new String();
if (arguments.length == 0)
var ErrorMessage = "Unknown error or exception";
else
{
if (typeof(Exception) == "object")
ErrorMessage = Exception.description;
else
ErrorMessage = Exception;
}
var ProcessName = Project.Variables.ProcessName;
var TerminationTimeOut = Project.Variables.TerminationTimeOut * 1000; // in milliseconds
Log.Error("Termination reason: " + ErrorMessage);
/* Checking application's process for existance */
if (!IsProcessExist())
{
Log.Message("Application's process is already terminated");
}
else
{
Log.Message("Attempt to terminate process...");
TestedApps.ScanMagic.Terminate(); // sending instructions to terminate process
}
aqUtils.Delay(TerminationTimeOut);
Log.Message("Stopping test case execution...");
Runner.Stop(true); // stopping current test only
}
This one works fine in most cases but sometimes application crashes with "Microsoft Visual C++ Runtime Library Error" window. According to received logs the application's process is already terminated but any actions, for example, aqUtils.Delay(...) or Runner.Stop(true) can't be performed before I activate any other application or press Windows' "Start" button manually. Only after this script continue it's work and stops.
I tried to simulate "Start" button pressing, and received click events in my log...but in real nothing has changed - application's window and modal error window described higher are still preventing normal script execution...
What's the reason? Can I solve this problem by any methods?
Thanks...