Synchronization in QTP

QTP has become the numero uno Test automation tool for testing mobile apps and desktop applications. Although it can be used for testing web based applications, very few are using it. Selenium dominates in this area.

 

At a time when mobile apps and desktop applications are gaining more significance and the computerization of many virgin areas creates a demand for new software applications, software testing is gaining more importance and there is a rush for learning test automation tools.

 

QTP, being one of the most widely used test automation tools in the world, there is a huge demand for QTP experts and since the courses guaranteeing good job opportunities the demand for QTP training is increasing like never before.

 

Synchronization in QTP is an important step in software testing using QTP and the tutorials teach this portion in detail. A synchronization point is the most used term in this portion of the course content and Synchronization Point is the time interface between the tool and the application under test. It is the feature to specify the delay time between the two steps of the test script. For example, the time to load a page after clicking on a link differs based on different criteria such as system specifications, network bandwidth, application server response time etc. If the tester cannot handle this time variations intelligently, the test will fail certainly. Here is the significance of inserting synchronization points wisely.

 

Ways to Insert Sync Points

There are many ways to insert sync points in QTP and they are as follows

WaitProperty

Property name, value, and timeout value will be taken as inputs to perform synchronization in this method. This option is encouraged as it is a dynamic wait.

‘ Method 1 – WaitProperty with 25 seconds
Dim obj
Set obj = Browser(“Math Calculator”).Page(“Math Calculator”)
obj.Link(“Numbers”).Clickobj.Link(“Simple Interest”).WaitProperty “text”, “Simple Interest”,25000
obj.Link(“Simple Interest”).Click

 

Exist

In this method, only timeout value will be taken as input for performing synchronization. This is also a dynamic wait and hence it is also encouraged.

‘ Method 2 : Exist Timeout – 30 Seconds
Dim obj
Set obj = Browser(“Math Calculator”).Page(“Math Calculator”)
obj.Link(“Numbers”).Click

If obj.Link(“Simple Interest”).Exist(30) Then
  obj.Link(“Simple Interest”).Click

Else
  Print “Link NOT Available”
End IF 

Wait

In this method, the test waits whether the event happened or not hence it can be used only for shorter waits such as one or two seconds. This is a hard coded synch point and is discouraged usually.

‘ Method 3 : Wait Timeout – 30 Seconds
Dim obj
Set obj = Browser(“Math Calculator”).Page(“Math Calculator”)
obj.Link(“Numbers”).Click
wait(30)
Browser(“Math Calculator”).Page(“Math Calculator”).Link(“Simple Interest”).Click 

Synch

This method of synchronization in QTP is exclusively for web based applications where there will be a lag between page loads.

‘ Method 4 :
Dim obj
Set obj = Browser(“Math Calculator”).Page(“Math Calculator”)
obj.Link(“Numbers”).Click

Browser(“Math Calculator”).Sync
Browser(“Math Calculator”).Page(“Math Calculator”).Link(“Simple Interest”).Click 

 

Inserting QTP Inbuilt Synchronization Points

Insertion of QTP inbuilt synchronization points can be done in easy five steps.

  1. Go to “Recording Mode”
  2. Go to “Design” and then to “Synchronization Point”
  3. Select the object that is to be the synchronization point. Object window will be opened
  4. Click “OK” in the object window and the “Add Synchronization” window gets opened. Add property name value and timeout value and click “OK”.
  5. The script would be generated by now which will be same as that of the WaitProperty method.

Default Synchronization

Even if the user has not used any of the above-mentioned synchronization methods, the QTP has an object synchronization timeout. It can be adjusted by the user.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>