In this article we show the difference between the Global.DoWaitFor and Global.DoWaitForProperty synchronization functions.

Let’s consider an example. We have an application that is doing some initialization during load:

Finally, when initialization is done, the “Proceed>” button appears on the screen:

Global.DoWaitFor is used when there is an object that may not exist on the screen before some point of time. In the AUT (application under test) we have a button "Proceed>>" that is not available until the app finishes loading. So here is how we can wait for the object:

if(Global.DoWaitFor('Proceed__', 15000))

{

     // We are here because DoWaitFor succeeded!

      ...

}

1st parameter represents an object by its Object ID, just like it is used by the SeS() function). 2nd is a timeout to wait for. If object is not found then DoWaitFor just returns false without writing anything to the report.

Global.DoWaitForProperty is used when there is an object that changes its state during the process and we need to wait for it to reach specific state. It may be progress bar or status message. In the considered application we have a Title (WindowText) that is visible all the time and finally it says "Ready" when the application is loaded:

So we wait for a specific value of the title, exactly what we do via Global.DoWaitForProperty:

if(Global.DoWaitForProperty('LoadingForm', 'GetWindowText', 'Ready', 15000))

{

      // We are here because DoWaitForProperty succeeded:

      // title is now 'Ready'

      ...

}

Please, note that the first parameter is an Object ID, similar to that used by DoWaitFor. The second parameter is getter function name or action name (i.e. GetWindowText, DoGetText or whatever is available for the given type of object). The third parameter is the expected value that we are waiting for. The last parameter is the timeout (in milliseconds).

If the object is not present or didn’t reach required the state, the function simply returns false after the specified timeout without writing anything into the report.

The attached sample test contains an AUT and a test case implementing both synchronization functions.