Forum Discussion
Julia_K
Alumni
14 years agoHello Deva,
Is the Close method you call within the try block executed successfully when you get that error message? Does the Close method called within the try block post any messages to the test log?
Maybe, instead of using the hardcoded delays within the try block, you would better set the timeout period for the Close method.
For example, please see the code below:
...
try
{
dlgSchedule = Sys.Process("mmc").WaitWindow("MMCMainFrame", "Task Scheduler", -1,1000);
dlgSchedule.Close(60000); // Waits until the window is closed for one minute
}
...
You need to set the timeout period long enough for the window to be closed.
Or you can try modifying your code in the following way:
function Test()
{
var dlgSchedule;
try
{
dlgSchedule = Sys.Process("mmc").WaitWindow("MMCMainFrame", "Task Scheduler", -1,1000);
dlgSchedule.Close(10000);
var i = 0;
while (dlgSchedule.Exists)
{
Delay(3000);
// Not to fall into an infinite loop if the tested window is frozen and cannot be closed
i ++;
if (i > 100)
break;
}
// Checks whether the window still exists
if (dlgSchedule.Exists)
Log.Error("The window has not been closed");
}
catch(exception)
{
Log.Error(exception.message, exception.description);
}
}
Please let us know whether this information helps you or whether you have any additional questions.
Thank you.