- WaitForControlReady() – This waits for the control to be ready to accept mouse/keyboard input. The engine implicitly calls this API for all actions to wait for the control to be ready before doing any operation. However, in certain esoteric scenario, you may have to do explicit call.
- WaitForControlEnabled() – This waits for the control to be enabled. For example, you can use this wait till the “Next” button of the wizard is enabled (where the wizard is doing some asynchronous validation of the input by making calls to the server).
- WaitForControlExist() – This waits for the control to exist on the UI. For example, you are expecting an error dialog after the application has done the validation of the parameters. The time taken for validation is variable. You can use this method here to wait for the error dialog.
- WaitForControlNotExist() – This waits till the control cease to exist on the UI. For example, you can use this for progress dialog to go away.
- WaitForControlPropertyEqual(string propertyName, object propertyValue) – This waits for the specified property of the control to have the given value. For example, you can use this to wait for the status text to change to Done.
- WaitForControlPropertyNotEqual(string propertyName, object propertyValue) – This waits for the specified property of the control to not have the given value. For example, you can use this for edit box to be not read-only i.e. editable.
- WaitForControlCondition(Predicate<UITestControl> conditionEvaluator) – This waits till the specified predicate returns true. This can be used for complex wait operation (like OR conditions) on a given control. For example, you can use this to wait till the status text is “Succeeded” or “Failed”.
The recommendation would be use Playback.Wait() API instead of Thread.Sleep() API. The reasons for this are -
- There is PlaybackSettings.ThinkTimeMultiplier using which you can modify you sleep. By default this variable is 1 but you can increase\decrease it to change the wait time all over the code. For example, if you are specifically testing over slow network (some other slow performance case), you can change this variable at one place (or even in the configuration file) to 1.5 to add 50% extra wait at all places.
- Playback.Wait() internally calls Thread.Sleep() (after above computation) in smaller chunks in a for-loop while checking for user cancel\break operation. In other words, Wait() lets you cancel playback before the end of the wait whereas sleep might not or throw exception.