QTP-Synchronization
Synchronization
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 points:
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 Milli 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.
Advantages of Wait Statement:
1) It is a VBScript statement, we can use this globally
2) It is recommended, whenever we want to observe the Test Execution process
3) No object reference required to insert wait statements
4) It is useful to make QTP capture values and screen shots during test execution
Inserting Transaction Points
QTP is providing a Utility object called Services for measuring transaction time
Suppose, we want to measure how much time that one test or part of the test is taking for execution/running, we can measure using these transaction point (Start and End)
Syntax:
Services.StartTransaction “Transaction Name”
Statements
——-
——
Services.EndTransaction “Transaction Name”
Statements
——-
——
Services.EndTransaction “Transaction Name”
Note: these options (Start and End Transactions) available in QTP tool Insert menu
Example:
services.StartTransaction “Login”
SystemUtil.Run “C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe”,””,”C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightapp”,”open”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set “naga”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4baf50f18b0ae0d5f5425fe760653e96da50bde7″
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Activate
services.EndTransaction “Login”
Note: We can insert number of transaction points in a test
SystemUtil.Run “C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe”,””,”C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightapp”,”open”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set “naga”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4baf50f18b0ae0d5f5425fe760653e96da50bde7″
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Activate
services.EndTransaction “Login”
Note: We can insert number of transaction points in a test
Using Timer Function
‘Timer’ is a VB Script Built-in function, that can be used for measuring transaction time.
ST=Timer’ It returns elapsed time since 12:00 AM Mid night in seconds
Example:
SystemUtil.Run “C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe”,””,”C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightapp”,”open”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set “naga”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4baf50f18b0ae0d5f5425fe760653e96da50bde7″
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Activate
ET=Timer
TT=ET-ST
msgbox TT
ST=Timer’ It returns elapsed time since 12:00 AM Mid night in seconds
Example:
SystemUtil.Run “C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe”,””,”C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightapp”,”open”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set “naga”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4baf50f18b0ae0d5f5425fe760653e96da50bde7″
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Activate
ET=Timer
TT=ET-ST
msgbox TT
Note: here ST, ET and TT are variables, you can take any variable, I used:
ST for Start Transaction
ET for End transaction
TT for Transaction Time
ST for Start Transaction
ET for End transaction
TT for Transaction Time
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.