bhoppe
15 years agoNew Contributor
Can't get TC to wait for app to become un-busy...
I have an application that I'm testing. I have TC click a button on the main window to open a new window that has an text input box and a button that when clicked creates a new design. At this point, the cursor turns to an hour glass. After the design is created, this design window goes away and I'm back to the main window. If there was an error with the text input, the design window stays up with the box highlited and the cursor back to a pointer. I repeat this process for different inputs to the text box. Now, the time it takes to create a design varies, so I can't just delay the test script 10 seconds, it has to be smarter.
I thought TC would wait for an application to stop being busy before continuing on with the test, but it doesn't. It waits for a little bit, but then just continues even though the application is in a busy state. So I tried to force TC to wait.
Here's what I've tried (C# script):
<snip>
// Bring up design window
p1["MainWnd"]["WinFormsObject"]("DesignButton")["Click"]();
w2 = p1["WinFormsObject"]("NewDesign");
// Click the design button.
// TC should wait for the application to come out of a busy state after this button is clicked.
w2["ButtonDesignNow"]["Click"](14, 17);
// In case TC continued before the application became unbusy, force it to wait for design to be created.
// Check if the design window is still up
while(p1["WaitWinFormsObject"]("NewDesign", 0)["Exists"])
{
// Check if the cursor is in a hourglass state
if(aqString["Compare"](p1["NewDesign"]["Cursor"]["Current"]["ToString"]["OleValue"], "[Cursor: WaitCursor]", false) == 0)
{
// Still busy creating design, wait a bit
Log["Message"]("Waiting for design to be created...");
aqUtils["Delay"](500);
}
else
{
// Done trying to create design, but design window is still up so there must be an error.
Log["Error"]("Invalid input.");
p1["WinFormsObject"]("NewDesign")["Close"]();
}
}
<snip>
The problem is that TC doesn't wait for the application to not be busy anymore. If the design creates within a couple of seconds, it works fine. But if it takes longer, I see in the playback info TC is waiting for "WinFormsObject NewDesign", then goes to waiting for "Application" object, then goes to waiting for "WinFormsObject MainWnd", then goes to trying to click DesignButton on the MainWnd. But I can see that the application is still busy and the NewDesign window is still up.
How do I get TC to wait while the application is busy?
I thought TC would wait for an application to stop being busy before continuing on with the test, but it doesn't. It waits for a little bit, but then just continues even though the application is in a busy state. So I tried to force TC to wait.
Here's what I've tried (C# script):
<snip>
// Bring up design window
p1["MainWnd"]["WinFormsObject"]("DesignButton")["Click"]();
w2 = p1["WinFormsObject"]("NewDesign");
// Click the design button.
// TC should wait for the application to come out of a busy state after this button is clicked.
w2["ButtonDesignNow"]["Click"](14, 17);
// In case TC continued before the application became unbusy, force it to wait for design to be created.
// Check if the design window is still up
while(p1["WaitWinFormsObject"]("NewDesign", 0)["Exists"])
{
// Check if the cursor is in a hourglass state
if(aqString["Compare"](p1["NewDesign"]["Cursor"]["Current"]["ToString"]["OleValue"], "[Cursor: WaitCursor]", false) == 0)
{
// Still busy creating design, wait a bit
Log["Message"]("Waiting for design to be created...");
aqUtils["Delay"](500);
}
else
{
// Done trying to create design, but design window is still up so there must be an error.
Log["Error"]("Invalid input.");
p1["WinFormsObject"]("NewDesign")["Close"]();
}
}
<snip>
The problem is that TC doesn't wait for the application to not be busy anymore. If the design creates within a couple of seconds, it works fine. But if it takes longer, I see in the playback info TC is waiting for "WinFormsObject NewDesign", then goes to waiting for "Application" object, then goes to waiting for "WinFormsObject MainWnd", then goes to trying to click DesignButton on the MainWnd. But I can see that the application is still busy and the NewDesign window is still up.
How do I get TC to wait while the application is busy?