Tag Archives: wait

Good Things Come to Him Who Waits (Instead of Sleeping)

I avoid putting sleeps into my test code. It’s never certain how much time is needed for the hoped-for state to be reached. And the sleep time has to be the longest time believed necessary, even if a much shorter time often would have served.

Waits are better, but I’ve had trouble with some CUIT wait methods, which sometimes seem not to have the desired effect: a search succeeds, but accessing the found control causes an exception.

Recently, I’ve added to the search code these wait method calls:

String state = UITestControl.PropertyNames.State;
ControlStates nvail = ControlStates.Unavailable;
ControlStates nvisi = ControlStates.Invisible;
foundControl.WaitForControlPropertyNotEqual(state, nvail);
foundControl.WaitForControlPropertyNotEqual(state, nvisi);

So far, they seem to be effective; I have not had a false search failure recently.