Transactions in UFT with Examples

Transactions in UFT can be used to measure how long does it take to execute a section or a few steps of your test.

For example, you can define a transaction to measures the length of time required to book a flight.

You can define transactions within your test by enclosing the required sections of the test with Start and End transaction statements. You can define as many transactions as you want and there is no limit for defining transactions. You can also define nested transactions.

Define Start and End Transactions in UFT

Let’s try to understand it with a simple example. I have recorded a test on the HPE Sample flight application. There are two functionalities involved in it.
  • Login to Flight application
  • Booking a Flight

UFT-Script

We can define the transaction to measure the time for each functionality. To insert a Strat Transaction for login functionality, set the cursor at line number 2 and select “Design>Start Transaction”.

Transactions in uft

The Start Transaction Dialog box will be displayed. In the Name field, you will have to provide a valid name and click on the OK button.

start transaction uft

The Start Transaction statement will be added at the line where the cursor was placed before.
Start-Transaction-UFT-9
In the same fashion, we can add the End Transaction. Set the cursor at line number 6 and select “Design>EndTransaction”.End Transaction dialog box will be displayed with the name what we provided for start transaction. Click on the OK button.
End Transaction UFT
The End Transaction will be added to the script as shown below.
Start and End Transaction UFT-05543
Repeat the same steps to add Start and End Transaction for Flight Booking functionality.
Start and End Transaction uft-09857
Run your Test Script and open the test result. You can see all Start and End Transactions in the result viewer. Upon clicking on the End Transaction it will show how long it has taken to execute the code for the specific section of the code. Here we can see that for LoginTransaction it took around 5.6323 seconds.
Start and End Transaction UFT Result
*Note: You can’t include spaces in a transaction name.

Recommended Posts

Leave a Reply