How to Use WaitProperty | Dynamic Wait in UFT

Synchronization is a mechanism that includes at least two segments required to play out any activity, we anticipate that these segments should cooperate at a similar pace. The coordination between these segments to run parallelly is called Synchronization.

dynamic wait in uft

Nowadays we see that the majority of the web applications are being developed by utilizing Javascript and Ajax where it may happen that a portion of the components has loaded but the object you are looking for is still being loaded because of which UFT may throw an error object not found during the execution.

In automation testing synchronization (Wait) has a significant value. In UFT we can use hard wait and dynamic wait to synchronize with required objects.

Hard Wait in UFT

The Wait method can be used to wait for the specified time. The Wait method accepts time in second as input.
For example, when you open the browser and navigate to an URL, it may take 3 to 10 seconds to load the login page completely. You can not enter login credentials unless the page is loaded completely.
So you can add a wait statement that will wait for 10 seconds.

Since you are adding a hard wait of 10 seconds. It means that even if the page gets loaded within 4 seconds, UFT will still continue to wait for 6 more seconds. Hence it is not a good approach to insert a hard wait where the wait time varies between 3 to 10 seconds. The hard wait should not be used where the wait time exceeds more than three seconds.

WaitProperty | Dynamic Wait in UFT

We should always use dynamic wait rather than hard wait where we are not sure how much time an object would take to load. In order to use dynamic wait in UFT, we can use WaitProperty method.


object.WaitProperty (PropertyName, PropertyValue, [TimeOut])


Parameter Description
PropertyName Required. A String value.
The name of the property whose value is checked.
PropertyValue Required. A Variant.
The value to be achieved before continuing to the next step.
TimeOut Optional. A long integer value.Time in milliseconds.
After which UFT continues to the next step if the specified value is not achieved. If no value is specified, UFT uses the time set in the Object Synchronization Timeout option in the Run pane of the Test Settings dialog box.
Default value = -1

We can replace the hard wait in the aforementioned example with the dynamic wait as shown below.

In the above example, UFT will wait up to 10 seconds. If within 10 seconds the UserName field becomes editable UFT will proceed to the next step rather than waiting exactly 10 seconds. Thus the execution time of the test script will decrease and the script will become more robust.

Recommended Posts

Leave a Reply