RSS

Adding Network Performance Analysis to a Quick Test Pro Script

Tue, Apr 21, 2009

Staff Posts, Tips and Tricks

This is the second post in the series that covers the use of QTP with VE Desktop. In the previous post I showed you how to add network conditions to a QTP script.

In this post I will expand the sample to automatically analyze the performance of transactions under network conditions. This leverages the built in packet capture and analysis capability within VE Desktop and leverages the VE Analyzer product for the reporting and analysis oprtion.

The process for adding the analysis is quite simple, it involves adding synchronization points at the end of each transaction as well as adding VE Desktop markers at the beginning and end of each transaction. The analysis itself can be triggered automatically at the end of the test.

First we need to add synchronization points at the end of each transaction so the playback will wait for the page to finish loading before ending the transaction. The easiest way to add synchronization points is during the recording of the QTP script, in this example the script waits for the “findFlights” button image to be visible before completing the “SignIn” transaction.

Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").Image("findFlights").WaitProperty "visible", true, 10000

More synchronization points need to be added, one for each transaction (for network analysis it is recommended to mark each none human intervention step in the script, i.e. from the “click the submit button” until the page loads).

Next we need to activate the packet capture before the test begins and we will also configure the analysis to run automatically at the end of the test, reminder in the previous post we defined the ctrl object which provides access to the VED client functionality:

'Activate the packet list and configure the auto analysis
ctrl.ActivatePacketList
ctrl.SetAutoAnalysisParams True, "HTTP", True

Finally we need to mark the beginning and end of each transaction so the VE Analyzer will be able to provide its analysis on a transaction be transaction basis. By default, if you don’t mark the transactions the analysis will be provided on the entire script, but as you will quickly find out, the ability to correlate the business logic to the analysis is very useful.

The marking of the transactions is done with the following functions:

ctrl.StartTransaction "SignIn"
' Transaction runs here
ctrl.StopTransaction 1

The final script looks like this:

'Load the COM interface for VE Desktop API
Set ctrl = CreateObject("ShunraVEAPI.ShunraVEDController")

'Just in case network conditions are already applied , stop the VED test
returnStatus = ctrl.StopTest()
If returnStatus  0 Then
	ctrl.GetLastError returnStatus, text
	Reporter.ReportEvent  micFail, "StopTest", text
End If

' check out a license from the VED server
returnStatus = ctrl.LicenseCheckout(5)
If returnStatus  0 Then
	ctrl.GetLastError returnStatus, text
	Reporter.ReportEvent  micFail, "License Checkout", text
End If

' Activate the packet list and configure the auto analysis and auto save
ctrl.ActivatePacketList
ctrl.SetAutoAnalysisParams True, "HTTP", True

' Activate the network conditions 50 msec latency, 0% packet loss and unlimited bandwidth (0)
returnStatus = ctrl.StartAdvanced (100,0,0)
If returnStatus  0 Then
	ctrl.GetLastError returnStatus, text
	Reporter.ReportEvent  micFail, "Start Advanced", text
End If

'BEGINNING OF THE QTP ACTION NOW WITH VED MARKERS
ctrl.StartTransaction "SignIn"
Services.StartTransaction "SignIn"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set "amichai"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("password").SetSecure "49c2a6682829d59b84f9eabf8c8d76a8557e"
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Image("Sign-In").Click 24,4
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").Image("findFlights").WaitProperty "visible", true, 10000
Services.EndTransaction "SignIn"
ctrl.StopTransaction 1

ctrl.StartTransaction "SearchFlight"
Services.StartTransaction "SearchFlight"
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromDay").Select "12"
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").Image("findFlights").Click 34,6
Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").Image("reserveFlights").WaitProperty "visible", true, 10000
Services.EndTransaction "SearchFlight"
ctrl.StopTransaction 1

ctrl.StartTransaction "SignOff"
Services.StartTransaction "SignOff"
Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").Link("SIGN-OFF").Click
Browser("Welcome: Mercury Tours").Page("Sign-on: Mercury Tours").Image("Login").WaitProperty "visible", true, 10000
Services.EndTransaction "SignOff"
ctrl.StopTransaction 1

'END OF THE QTP ACTION

'Stop the network impairments
returnStatus = ctrl.StopTest()
If returnStatus  0 Then
	ctrl.GetLastError returnStatus, text
	Reporter.ReportEvent  micFail, "StopTest", text
End If

returnStatus = ctrl.LicenseCheckin()
If returnStatus  0 Then
	ctrl.GetLastError returnStatus, text
	Reporter.ReportEvent  micFail, "License Check In", text
End If

'Release the COM object
Set ctrl = Nothing
, , , , , ,

share

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes