Timing and Waiting

Apr 21, 2008 at 2:03 PM
Hi,

Since we've been using White its become clear to us that to write reliable tests were having to proactively build into our functions code that allows the application time to respond.

Example 1:

So where we started with:

currentlySelectedTabItem.RightClick();
mainWindow.PopupMenu("Close").Click();


We ended with as the above was unreliable on our fast build machines:

currentlySelectedTabItem.RightClick();
Thread.Sleep(100);
mainWindow.PopupMenu("Close").Click();
Thread.Sleep(100);


Example 2:

So where we started with:

Button test = mainWindow.Get<Button>(searchCriteria);

We ended with as the above was unreliable on our fast build machines:

public static T GetAndReturnControlWithWait<T>(Window mainWindow, SearchCriteria searchCriteria, int tryFor) where T : WhiteCore.UIItems.UIItem
{
int tryCount = 0;
T control = mainWindow.Get<T>(searchCriteria);

while ((tryCount <= tryFor) && (control == null))
{
control = mainWindow.Get<T>(searchCriteria);
System.Threading.Thread.Sleep(sDefaultPauseInteraval);
tryCount++;
}

if (control == null)
{
throw new WhiteCore.AutomationException("Control was not found on : " + mainWindow.Name);
}
else
{
return control;
}
}


Is there anyway you could tackle these issues inside White? Is there something we're missing about the way we're using White?

Thanks,

James.
Apr 21, 2008 at 2:05 PM
In response to your comment on documenting on the home page, can I suggest the Wait Handling area as a candidate for documentation, maybe if I understood how this works and how to configure it I may not have to be as defensive in my test code.

Thanks,

James.
Coordinator
Apr 21, 2008 at 6:18 PM
Edited Apr 21, 2008 at 6:20 PM
You should have a look at the Wait Handling section.
Your first problem can be solved easily by setting the PopupTimeout property.

Second one is bit odd, because once the window is available, all the items in it should become available as well. So there might be an issue with getting a window in which all the UIItems are not available. This is possible. Hence I am going to add WaitForInputIdle after the window element is found by Application. You can do the same on window by calling the method after retrieving from the Application object. There is going to be a release, tomorrow I think which should have this, in it.

I am curious to know whether you have hour glass shown in your application when it is busy? And if it is, then are you using the WaitWhileBusy. One of the main ideas of white is to eliminate all the reasons for putting thread.sleep and retrying, these all belong inside white, not outside. Hence if you find problems in this area please raise an issue.
Apr 22, 2008 at 12:22 PM


viveksingh wrote:
You should have a look at the Wait Handling section.
Your first problem can be solved easily by setting the PopupTimeout property.



I'll try setting PopupTimeout programitically and see if that helps.


viveksingh wrote

Second one is bit odd, because once the window is available, all the items in it should become available as well. So there might be an issue with getting a window in which all the UIItems are not available. This is possible. Hence I am going to add WaitForInputIdle after the window element is found by Application. You can do the same on window by calling the method after retrieving from the Application object. There is going to be a release, tomorrow I think which should have this, in it.

I am curious to know whether you have hour glass shown in your application when it is busy? And if it is, then are you using the WaitWhileBusy. One of the main ideas of white is to eliminate all the reasons for putting thread.sleep and retrying, these all belong inside white, not outside. Hence if you find problems in this area please raise an issue.


We found that on our normal test machines we didn't have to be as defensive when getting UIItems but on our high specified build machine (3Ghz Quad Core Xeon Processor, v. fast FSB, v. fast RAM) if we weren't defensive as I describe then then we just wouldnt get the UIItems successfully on the first attempt. It just seemed like the .get would happen before the application was ready.

I look forward to the new release :)

Thanks,

James.