Synchronization in QTP or UFT

Spread the love
  • 1

Synchronization in QTP/UFT
Synchronization in QTP/UFT


Synchronization in QTP/UFT:

Synchronization is referred to waiting time in the sense that if you have an application in which you have 3 steps for example. Let’s say you are recording the steps where the first step is to enter the information, second step is clicking submit button and third step is get the order No.This is like our flight reservation system.Now when you click submit button it may take few seconds to several minutes depending on the application or internet speed. After that we can get the order no.But when you play this in Qtp it does it very fast, it does not wait for processing of information after you click submit button and may try get the order no before it is getting generated which will give error. So, to overcome such problems we insert synchronization point. By inserting synchronization point we are asking QTP to wait till the order no is getting generated and then retrieve the order no.
It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.So Synchronization acts as a time interface between the tool(QTP or UFT)a and the underlying application(UAT).

Where Synchronization is required:

During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required.
There are several methods available in QTP for synchronization.
  1. Inserting Wait statements.
  2. Inserting Synchronization points.
  3. Increasing Tool default synchronization time.
  4. Sync Method (Only for WEB)
  5. Exist Property

Inserting Wait Statements:

We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation.Wait is a hard-coded delay (wait X number of seconds). Wait should be avoided as much as possible. The script will run faster and more reliably if you use the built in synchronization functions of QTP (WaitProperty or Sync).This command is used to stop QTP(forcefully) for the specified time.If you are very sure within that time frame the Application is bound to open ,It is very smart to use it.

Wait(time in seconds)
Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.Wait is a hardcoded sync point.

Inserting Synchronization point:

Place cursor in desired location>keep tool under recording mode > Insert menu > Synchronization point > show the object > click ok > select property name & Value (True)>enter time in Mille seconds>click ok>Stop recording.
Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately.
object hierarchy.waitproperty “property name”,value,time in milli seconds.

Increasing Tool default synchronization time:


File>settings>run tab>increase object synchronization time out>apply>ok
Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately.
Sync Method: (only for WEB)
Waits for the browser to complete current navigation.


Object Hirearchy.Sync

Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync

Selecting an appropriate Method:

Suppose in our test one or more statements only are taking more time for execution then selecting “Inserting synchronization method” is better.Suppose in our test more statements are taking more time for execution then selecting “increasing tool time out”.Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions.


WaitProperty takes input as the property name, Value and Timeout value and waits for the property to appear in the screen for the specified Timeout value

Syntax –

object.WaitProperty(PropertyName, PropertyValue, [TimeOut])
(TimeOut Parameter is optional, incase it is not given it would take the default synchronization time “File –> Setting –> Run –> Object synchronization timeout”)

Set object = Browser("CreationTime:=0").Page("Index:=0").Link("text:=Accounts", "html tag:=A").WaitProperty "text","Accounts",3000


Exist takes input as the Timeout value to sync. It waits for the specified timeout value to check if the object has appeared or not.

Set object = Browser("CreationTime:=0").Page("Index:=0").Link("text:=Accounts", "html tag:=A")
If object.Exist(5) Then
End If 


Sync Method

Sync Method can be used only for web applications where there is always a lag between page loads.

Syntax –



Browser.Sync or Page.Sync waits for the navigation to complete, which means that the page has been downloaded completely and successfully. This does not necessarily mean that all of the elements of the page have been downloaded (i.e., images, CSS, JS).

Asynchronous browser and scripting:

UFT/QTP  does not support asynchronous browser scripting(ajax) in a direct way.For these cases, we can use browser’s readyState or busy property.
The syntax is as follows:

until ie.readyState = 4 loop
busyCode= Browser("CreationTime:=0").getROProperty("busy")
However they are not that reliable.

A sure fire Approach:

We can change the code a little bit

until Browser().Page().Object.Exits(2) loop


Another approach I liked:

function WaitForObject(obj)
WaitForObject = false
Setting(“DefaultTimeout”) = 500
for i = 0 to 30 ‘or more
If obj.Exist Then
WaitForObject = true
Exit For
End If
Setting(“DefaultTimeout”) = 20000 ‘ or other value

end function



To my point of view the best approach is
'ARGUMENTS : obj,Max_Wait,result
'DESCRIPTION : Waits for Oracle Navigator
'RETURNS : None '
Function F_Sync (obj,Max_Wait)
Dim Wait_Time flag_wait = "False"
If obj.Exist(2) then
Else Wait_Time=Wait_Time+5 
If Wait_Time> Max_Wait Then 
Exit do 
End If 
End If 
loop until flag_wait = "True" 
End Function
obj will be
Set obj=Browser("ABC").Page("VCV")

Instead of String we can use boolean as well.


Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1


  1. Hello!

    I’ll keep this brief and to the point as I know you’re busy. I found your site today and noticed it’s not ranking well on
    Google for some of your main keywords, not where they should be anyway.

    I currently have a free 30-day SEO trial offer on my site and wanted to see if you’d be
    interested in letting me help you improve your on-page SEO and get some fresh backlinks
    flowing to your site.

    Have a great day and I’ll talk to you soon!

    Kind regards,


Please enter your comment!
Please enter your name here