Advanced HTTP script editing in Rational Performance Tester

Reduce effort by modifying existing scripts, rather than creating new ones

Recording and customizing scripts to create a test framework involves a lot of effort. A small change in the application user interface or use case can make the scripts unusable. IBM Rational Performance Tester includes several powerful yet not so widely known script editing features that you can use to modify all HTTP components of a page to adjust them to changes in the application. Priyanka Arora describes how testers can use these features to edit HTTP elements of a web page, including connection, request, response, headers, and content. She explains how you can extend these features to add new pages to existing test recordings. Then she offers a few methods that can help in determining when and what to add or modify in a script to bring it in line with changes in the application and the environment.

Share:

Priyanka Arora (prarora803@gmail.com), Performance Analyst, Bodhtree Solutions Inc.

Photo of Priyanka AroraPriyanka Arora is a Solution Performance Analyst. She has more than four years of experience, with strong technical analysis, tuning, troubleshooting, tools, and load test creation and execution of end-to-end performance engagements for several large telecom and public sector customers of IBM in India and in the Unites States. She earned an MSc Tech degree in Information Systems from Birla Institute of Technology and Science in India and is a certified WebSphere Application Server and Portal Server Administrator.



29 May 2012

Also available in Chinese Russian

Introduction

Modern IT applications and solutions go through several builds, release cycles, bug fixes, and code enhancements. These code changes often either render the test scripts obsolete or result in a lower page and element status code success rate during playback. Re-recording does not always have to be the only solution. IBM® Rational® Performance Tester provides the capability to change every element of a web page, making it feasible to accommodate almost any kind of change to the front end of an application into the test framework.

This article explains how to use these features. It is divided into the following three topics:

  1. Modifying elements of web pages in an existing test script, such as the connection, request, and response elements.
  2. Adding new pages to existing scripts.
  3. Methods that you can use to determine what elements to add or modify.

Editing the elements of a test

A web page consists of one primary and several secondary requests. Each request has an associated connection object, request attributes, headers, and, optionally, data. Each request in Rational Performance Tester is also linked to a response that was received from the server when the recording was created.

This section shows the procedure for modifying these request, response, and connection objects.

Connection

A connection object is defined by a host and port. Optionally, it can contain SSL and proxy information.

Change in connection information

A change in the application host or port needs to be reflected in the Rational Performance Tester test script. To achieve this:

  1. Expand the primary request of the first page in the script and select the Connection element.
  2. On the upper-right, under Test Element Details, right-click on the value of Host.
  3. Go to the connection variable, as shown in Figure 1, to open the Server Connections under Test Variables.
Figure 1. Modifying connection in a test script
Editing connection element of a web page

Larger view of Figure 1.

  1. On the upper-right, under Test Element Details, enter the new hostname for the application under test.
  2. Repeat steps 2 through 4, but this time with the Port, instead.

Change in authentication and security

If your application moves behind a proxy server, changes the current proxy settings, or adds or removes SSL encryption, you will need to change the authentication and security elements of the connection object.

Add a proxy

To add proxy to a request:

  1. Right-click on the connection object of the request in Test Contents.
  2. Select Add > Proxy.
  3. Enter the values for Host and Port under Test Element Details, as shown in Figure 2.
Figure 2. Adding a proxy to a connection
Adding proxy data to a connection variable
  1. Save the test and repeat this for all connection objects as required.

Tip:
You can follow similar steps to change an existing proxy in the test.

By doing this, you have changed the proxy at the connection level. Therefore, all requests using this connection object will now use the modified proxy settings.

Add authentication

To add SSL encryption to a request:

  1. Right-click on the connection object of the request in Test Contents section.
  2. Select Add > SSL.
  3. Under Test Element Details, select a value from the Protocol drop-down menu.
  4. Select the cipher name from the Available Ciphers list, as shown in Figure 3.
  5. Save the script and test it.
Figure 3. Adding SSL encryption to a connection
ConnectionEditing tab view

Tip:
You can use a similar method to change an existing security setting in the test.

All requests using this connection object will now use the modified security settings.

Usually, all requests of a script use the same connection object. However, more complex applications require creation of different connection objects for different requests, depending on which host they are routed to. Ensure that all connection objects in the test script are modified as required.

Request

An HTTP request consists of a method, a URL, headers and an optional body containing data.

Attributes

To modify the attributes of a request:

  1. Select the request under the Test Contents section of the ConnectionEditing tab.
  2. On the right, under Test Element Details, change the value of the URL, Version, or Method as desired. To change Host or Port, see the instructions in the Connection subsection.
  3. To edit URL components that have been substituted (marked in pink), you will first have to remove the substitution. Select the substituted component, right-click click Remove Substitution as shown in Figure 4.
Figure 4. Modifying request attributes in Rational Performance Tester
Changing URL of a primary request in a test script

Larger view of Figure 4.

  1. In response to the confirmation dialog window, click Yes.

You should now be able to define a new URL.

Headers

To add, remove, or modify existing headers in a request:

  1. Select the request under the page in the Test Contents section.
  2. To add a header, under Request Headers in Test Element Details, click Add.
  3. In the Add/Edit Headers window, search for the header that you want to add to the request, for example Cache-Control. If you do not find the header you are looking for in the list, select Custom from the Header Types list, type in the header name and value, and click Insert.
  4. Click on the > button to add the selected header to the list, and define the value, as shown in Figure 5.
Figure 5. Changing request headers
Adding a header and its value to a request
  1. Click on OK and save the test.

Tip:
You can follow similar steps to modify existing headers.

Response

Response to an HTTP request consists primarily of a Status, Headers, and Content.

To access the elements of a response, expand the request in the Test Contents area, and click Response. You will see response elements under Test Element Details on the right.

Headers

You can add or modify response headers in the same way as request headers. See instructions for Headers under the Request topic for details.

Content

To modify the content of a response, open the response and, under Test Element Details, select the value under Content under, as shown in Figure 6. You can either replace this with the new content or just edit the sections as necessary.

Figure 6. Modifying content of a response
ResponseEditing tab view

Larger view of Figure 6.


Adding a new page to an existing recording

At times, it is less effort to add a new page in an existing recording, rather than creating a whole new recording and re-customizing it. To avoid the rework, follow these next steps.

Create an empty page

To add a page, you will first need to create an empty page and then add HTTP elements such as connection, request, and response to it. To create an empty page:

  1. Under Test Contents, select the page before the one where you need to add a new page.
  2. Right-click and select Insert > HTTP Page.
  3. In the Select Server Connection window, either select an existing connection from the test or create a new connection for this page. If you are creating a new connection and intend to use it further in the test, choose to create test variables for it, as shown in the Figure 7.
Figure 7. Adding connection to a new page
Adding a new connection to a new page in Rational Performance Tester
  1. Under Test Element Details, give the page a Title and a Think Time.

Add requests

By default, Rational Performance Tester creates a new page with one primary request. You will need to add attributes to this request and add secondary requests, if any. In this section, you will see how to complete the primary request and add secondary requests.

To modify a primary request:

  1. Expand the page, and click on the primary request.
  2. Under Test Element Details, enter a value for the URL of the request beyond the host and a method (GET or POST).
  3. If test data needs to be added, click Add under Data.
  4. Select the added row, and click Modify.
  5. Enter the text data in Data Chunk.
  6. Add request headers. See instructions for Headers for more details.

After completing these steps, the request should look as shown in Figure 8.

Figure 8. Adding requests to a new page
A primary request added with headers and data

Larger view of Figure 8.

Add responses

To add response to a request:

  1. Under Test Contents, expand the request.
  2. Select the response element.

See the Response topic for detailed steps on adding or modifying response headers and content. After you have added all of the elements, the response should look as shown in Figure 9.

Figure 9. Adding response to a request in a new page
Response to a new request with headers and content

Larger view of Figure 9.


Determining when and what to add or change

It is easy to conclude that something in the application or the environment has changed when the change is substantial enough for the test scripts to fail. A detailed look at the test logs can indicate differences between expected and received responses. However, it is not always straightforward to narrow it down to what has changed. If the application, the network, or the operations team fails to point out any obvious changes, you can resort to one of the following methods. These methods also come in handy when adding new pages or requests to an existing recording.

Browser tools

There are several web-monitoring tools on the market that track and record the HTTP interaction between a web browser and a server. One such tool is the free IBM Page Detailer from IBM Research (see the Get Products and Technologies section in Resources for a link). It decomposes a web page into its component parts and the activities involved in retrieving them.

You can use the Page Detailer to view values of all HTTP elements, such as request and response headers, primary and secondary requests, and many more, as Figure 10 shows. It can be a simple solution to troubleshooting script failures, editing elements, and even adding new pages to existing scripts.

Figure 10. Web page components shown in the IBM Page Detailer
Page Detailer showing contents of a page

Larger view of Figure 10.

Page source

Web monitoring tools are helpful to determine values of headers and other elements. To get the actual content of a response, you can view the page source. Follow these steps:

  1. Open the URL of the primary or secondary request in a web browser.
  2. Right-click on the page, and go to View Source.

This will open a new window that displays the web page content (see Figure 11).

Figure 11. Page source of a web page
Content of a web page shown by page source

Larger view of Figure 11.

In conclusion, the effort involved in maintaining a test framework can be reduced by modifying the existing scripts, rather than creating new ones, whenever possible.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=818309
ArticleTitle=Advanced HTTP script editing in Rational Performance Tester
publish-date=05292012