On Web Load Testing

Extracting values from server responses

In this post I will continue using the profile mentioned here as an example. It contains a user session recorded at the following web forum: http://www.loadtestingtool.com/forum

The session is very simple: the user opens the main forum page, enters into a sub-forum by clicking a link on that page and then clicks another link to display a topic. I made a small modification to that profile: I removed requests to iframes, because they are static and do not play any role in the session. So, the whole session now consists of 3 requests:

GET /forum/ HTTP/1.1
GET /forum/index.php?showforum=11 HTTP/1.1
GET /forum/index.php?showtopic=2148 HTTP/1.1

As I mentioned before, the number of sub-forum in the second request is passed as the value of the showforum parameter. Same way the number of topic is included in the last request as the value of the showtopic parameter.

We can easily change these values to any other valid numbers. As a result, when the session is replayed, the virtual user will open sub-forums and topics with the corresponding numbers. However this is not what we usually need when performing a load test, because we want different users to perform similar, but still different actions on the web site.

In our case it would create a much more realistic load on the web site, if each virtual user in each session would enter into a random sub-forum and then open a random topic inside that sub-forum. In other words, it should click a random link to a sub-forum on the first page and then click a random topic link on the next page. I am going to show how to implement such parameterization of this profile with WAPT.

First of all, let’s review the content of the main forum page. It contains many links to different sub-forums. I pasted several lines from the raw HTML code of that page below.

<b><a href="http://www.loadtestingtool.com/forum/
index.php?showforum=11">How to solve my problem</a></b>
<b><a href="http://www.loadtestingtool.com/forum/
index.php?showforum=6">Test Scenario Creation</a></b>
<b><a href="http://www.loadtestingtool.com/forum/
index.php?showforum=9">User Session Emulation</a></b>

By the way, it is very easy to find anything like that inside a recorded server response using WAPT. You just need to select the corresponding request in the left view and then open the “Response processing” tab in the right view. Here you can use the “Find” feature to find and highlight all occurrences of the search string.

So, as we see now, all links to sub-forums are very similar to each other. They are different only in the values of the showforum parameter that we need to extract from here. Now I select the next page_2 request in the left view. This is the request that opens a sub-forum. The right view displays the request properties, including the showforum parameter specified for now by the static value (“11”).

I want to change the specification of this parameter, so that in each user session WAPT would open a random sub-forum. I select the parameter and click the “Edit” button. The “Edit Parameter” dialog is displayed.

I click the “Edit” button in it to change the function that calculates the value of that parameter. I change it from “Static test” to “Search parameter” and specify the following options for it.

As follows from the specification of this function, it searches the content of the latest server response (in our case it is the content of the main forum page, the response to page_1) in order to find a string of text surrounded by the two specified boundaries.

In general this function can find several occurrences satisfying this condition. This is exactly what happens in our case. That is why I specified “0” in the Index option. This will make the function return random occurrence.

The showtopic parameter in the last request can be specified in a very similar way.

Note that it is not necessary to extract the data from an URL. In the above example I specified boundaries so that the number is taken from a comment inside the HTML code of the page. We only need to make sure that the corresponding part of the code is always provided by the server.

Now let’s check how it works. I click the “Verify test” button on the toolbar to execute a sample user session with our profile. After the process is finished, WAPT shows the following log.

Now I verify it again and check the log. The parameterized values are different. This confirms that the randomization works as expected.

Now I can specify test volume and execute the test with several users. If I enable full logging for the test run (it is disabled by default for efficiency reasons), I can see that all executed sessions have randomized values of the mentioned parameters. So, different virtual users open different topics on the web site, thus demonstrating a rather realistic behavior.