Wednesday, 23 January 2013

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”
 
Note: these options (Start and End Transactions) available in QTP tool Insert menu
Example:
services.StartTransaction "Login" SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","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 Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","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

No comments:

Post a Comment