JMeter – HTTP URL Re-writing Modifier

As we had seen that HTML Link Parser PreProcessor extracts all the HTML links from the response of the previous request and then passes the random link to the successive request (under which HTML Link Parser is added as a child element). In JMeter, the ‘HTTP URL Re-writing Modifier’ works similarly to the HTML Link Parser, except it has a specific purpose for which it is easier to use than the HTML Link Parser and more efficient. For stateless HTTP protocol and Web Servers, the use of URL Re-writing is to store session ids instead of cookies and add them to every request of that ThreadGroup, under which this element is attached. Also, this modifier can be attached to select requests and it will modify only them. As we know that the HTTP protocol and Web Servers are stateless. This means that every request and response are independent, and can’t be identified by a previous request. But we need to know if a request is coming from the same user as their previous requests, and we need to be able to properly process all requests that come from the same user. 

Let’s try to understand this scenario with an example. I want to recharge my mobile without login to my telecom vendor application, so I just select “Postpaid”, enter the mobile number and click “Go”.

JMeter - HTTP URL Re-writing Modifier Example
Figure 01

On the next page, I will fill in the amount and click “Proceed”. You can see that I did not log in to the application.

Figure 02

On proceeding, I moved to the payment page where I can complete the bill payment.

Figure 03

Now, in the whole scenario, the user session played an important role. All actions by the same user from the same client (whether by the browser or mobile app) are the same Session. So the session data needs to be passed between the server and client in every request and response. One of the approaches to storing this session is URL Rewriting. In URL Rewriting, the session ID is added to each URL, and it will be received on the server side and processed accordingly. This enables the server to process complete sessions. However, if we navigate through the website with JMeter, the test will fail, since no session information was provided to the requests.

JMeter - HTTP URL Re-writing Modifier
Figure 04

How to add an ‘HTTP URL Re-writing Modifier’?

Follow the below steps:

  1. Select the appropriate element where you want to capture the value
    1. Thread Group
    2. Controller
    3. Sampler
  2. Right-click on the element
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘PreProcessor’
  5. Click ‘HTTP URL Re-writing Modifier

What are the input fields of the ‘HTTP URL Re-writing Modifier’?

‘HTTP URL Re-writing Modifier’ has the following input fields:

  1. Name: To provide the name of the preprocessor
  2. Comments: To provide arbitrary comments (if any)
  3. Session Argument Name: The name of the parameter to grab from the previous response. This modifier will find the parameter anywhere it exists on the page, and grab the value assigned to it, whether it’s in an HREF or a form. This is a mandatory attribute.
  4. Path Extension: Some web apps rewrite URLs by appending a semi-colon plus the session id parameter. Check this box if that is so. This is an optional attribute.
  5. Do not use equals in path extension: Some web apps rewrite URLs without using the” = ” sign between the parameter name and value. This is an optional attribute.
  6. Do not use questionmark in path extension: Prevents the query string to end up in the path extension.
  7. Cache Session Id?: Should the value of the session Id be saved for later use when the session Id is not present? This is a mandatory attribute.
  8. URL Encode: URL Encode value when writing parameter. This is an optional attribute.

You may be interested:

Leave a Comment