Thursday, 4 August 2016
TryFind vs WaitForControl(Ready/Exist)
TryFind() changed the test execution. The reason is that TryFind() would return true/false immediately when pages are still loading and its returned value would heavily depend on the responsiveness of the web server, so some tests would be fixed by simply replacing it with WaitForControlExist() which would block the current thread until timeout specified by default PlaybackSettings.WaitForReadyTimeout.
However prefer specifying timeout setting explicitly by calling WaitForControlReady(int millisecondsTimeout) or WaitForControlExist(int millisecondsTimeout). Somebody might accustomed with Playback.Wait(int thinkTimeMilliseconds) or Thread. Sleep(int millisecondsTimeout), but they might wait unnecessarily long.
In addition, if combined with Assertion as be;pw:
Unexpected delay could be highlighted immediately.
There are multiple WaitForControl() functions defined with UITestControl, some of them could be very helpful but are usually neglected, for example: