Synchronization in UFT is a generic way to have specified amount of time for an object to process prior to moving to next step. “ReadyState” is one of the best possible way to synchronize, generally used to wait till the full loading of DOM tree and used as like
Ready State Property
Every XML and HTML document in any HTML/web application is called as Document. Every time the document gets loaded/removed based on the navigation/action is performed by the user. Each document has a current document readiness which is set depending on the current document readiness status. The same applies for the objects in the document as well.
‘readystate’ property of the document retrieves the value, that indicates the current state of the document readiness.
when you set a url to load a particular page, the value will be set as ‘loading’ if the page is associated with a parser like HTML or XML parser. Once the parsing is done and page is loaded, the value will be set as ‘complete’.
The possible values of readystate are-
‘complete‘ when the object is completely initialized.
An object’s state is initially set to uninitialized, and then to loading. When data loading is complete, the state of the link object passes through the loaded and interactive states to reach the complete state.
This property can be used to synchronize the test steps better, which involves loading/navigation of pages. This will give you the exact sync between the two steps. for example if you want to wait till the page loads completely.
Do while ((Browser().Page().Object.ReadyState<>"complete" wait(1) Loop