Header Ads

Synchronization in QTP


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.
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.
Syntax:
Wait(time in seconds)
Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.
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.
Syntax:
object hierarchy.waitproperty "property name",value,time in milli seconds.
Increasing Tool default synchronization time:
Navigation: 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.
Syntax: Object Hirearchy.Sync
Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync
Selecting an appropriate Method:
  1. Suppose in our test one or more statements only are taking more time for execution then selecting "Inserting synchronization method" is better.
  2. Suppose in our test more statements are taking more time for execution then selecting "increasing tool time out" .
  3. 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.
These are general Synchronization methods applicable to general systems. Please visit
http://relevantcodes.com/qtp-synchronization-for-ajax-applications/

for synchronization in Ajax application.

Powered by Blogger.