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:
- Modifying elements of web pages in an existing test script, such as the connection, request, and response elements.
- Adding new pages to existing scripts.
- 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.
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:
- Expand the primary request of the first page in the script and select the Connection element.
- On the upper-right, under Test Element Details, right-click on the value of Host.
- 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
- On the upper-right, under Test Element Details, enter the new hostname for the application under test.
- 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:
- Right-click on the connection object of the request in Test Contents.
- Select Add > Proxy.
- Enter the values for Host and Port under Test Element Details, as shown in Figure 2.
Figure 2. Adding a proxy to a connection
- Save the test and repeat this for all connection objects as required.
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.
To add SSL encryption to a request:
- Right-click on the connection object of the request in Test Contents section.
- Select Add > SSL.
- Under Test Element Details, select a value from the Protocol drop-down menu.
- Select the cipher name from the Available Ciphers list, as shown in Figure 3.
- Save the script and test it.
Figure 3. Adding SSL encryption to a connection
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.
An HTTP request consists of a method, a URL, headers and an optional body containing data.
To modify the attributes of a request:
- Select the request under the Test Contents section of the ConnectionEditing tab.
- 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.
- 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
- In response to the confirmation dialog window, click Yes.
You should now be able to define a new URL.
To add, remove, or modify existing headers in a request:
- Select the request under the page in the Test Contents section.
- To add a header, under Request Headers in Test Element Details, click Add.
- 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.
- 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
- Click on OK and save the test.
You can follow similar steps to modify existing headers.
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.
You can add or modify response headers in the same way as request headers. See instructions for Headers under the Request topic for details.
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
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:
- Under Test Contents, select the page before the one where you need to add a new page.
- Right-click and select Insert > HTTP Page.
- 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
- Under Test Element Details, give the page a Title and a Think Time.
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:
- Expand the page, and click on the primary request.
- Under Test Element Details, enter a value for the URL of the request beyond the host and a method (GET or POST).
- If test data needs to be added, click Add under Data.
- Select the added row, and click Modify.
- Enter the text data in Data Chunk.
- 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
To add response to a request:
- Under Test Contents, expand the request.
- 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
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.
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
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:
- Open the URL of the primary or secondary request in a web browser.
- 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
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.
- Find out more on the Rational Performance Tester product overview page. Then explore the Rational Performance Tester page on IBM developerWorks for links to technical articles and browse the documentation in the Rational Performance Tester Information Center (or go directly to the Version 8.2 information center). You can also download Using Rational Performance Tester Version 7 from IBM® RedBooks®.
- Visit the Rational software area on developerWorks for technical resources and best practices for Rational Software Delivery Platform products.
- Subscribe to the developerWorks weekly email newsletter, and choose the topics to follow. Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Improve your skills. Check the Rational training and certification catalog, which includes many types of courses on a wide range of topics. You can take some of them anywhere, any time, and many of the "Getting Started" ones are free.
Get products and technologies
- Download the trial version of IBM Rational Performance Tester.
- Download the IBM Page Detailer.
- Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.
- Join the Performance Testing forum, where you can share you questions and knowledge about IBM performance testing products.
- Rate or review Rational software. It’s quick and easy.
- Share your knowledge and help others who use Rational software by writing a developerWorks article. Find out what makes a good developerWorks article and how to proceed.
- Follow Rational software on Facebook, Twitter (@ibmrational), and YouTube, and add your comments and requests.
- Ask and answer questions and increase your expertise when you get involved in the Rational forums, cafés, and wikis.
- Get connected. Join the Rational community to share your Rational software expertise and get connected with your peers.