The White framework does not send an action until a window has entered the idle state after the previous action. In that case, White framework waits automatically if a window is busy.
But how to wait for an element or a particular condition? How to avoid Thread.sleep during automation script development? In White, we can write our synchronization points. In this article, we will show you White framework waiting techniques and commands which are being used in all our desktop automation testing projects at Codoid.
Wait Based On HourGlass
Using WaitBasedOnHourGlass property (default value true), you can configure wait based on presence of hour glass.
CoreAppXmlConfiguration.Instance.WaitBasedOnHourGlass = true;
WaitTill is one of the methods for Window object. You can use this method to wait until the certain condition matches.
Label lbl = window.Get
In the above example, the script waits until the label field visibility=true. The default wait time is 5000 milliseconds.
You can also change the Default wait time by setting BusyTimeout property as shown below.
CoreAppXmlConfiguration.Instance.BusyTimeout = 10000;
Window window = application.GetWindow("Calculator");
WaitWhileBusy method makes your script wait until the window is busy. Note: You no need to call this method for every action as it is called automatically at the end of every action.
If you want to write your custom delay and the written custom code needs to be called after every action, then you can use IWaitHook interface as shown below.
public class CustomWait : IWaitHook
CoreAppXmlConfiguration.Instance.AdditionalWaitHook = this;
// Implementation of the IWaitHook interface
public void WaitFor(UIItemContainer uiItemContainer)