URL Redirection in LoadRunner – How to capture it properly

There will be scenarios during which a website will redirect to another URL which should be captured by LoadRunner so that the scripts can capture the URL redirection in LoadRunner to replicate the real time scenario.

How to capture the URL that is formed because of redirection?


When visiting http://www.mercury.com, user will be redirected to a different location. How to capture the redirected URL.


Use web_reg_save_param()

When that the server redirects a HTTP request to another URL, it normally does that by sending a HTTP 302 Moved header. To verify

1. Run the script in extended log with “data retuned by server’ turned on

2. Check the execution log for “302 moved’

You can also see that along with this header, the server also sends the following header information:

“Location: <URL>.”

The URL specified in the “Location’ header will be the URL that the original HTTP request be redirected to. To capture this URL, you have to capture the string between “Location:” and “\r\n” (end of line).




//use the correlation statement to capture the redirection

web_reg_save_param (“Redirection”, “LB=Location: “,”RB=\r\n” ,LAST );

//Visit Mercury homepage

web_url(“Mercury”,”URL=http://www.mercury.com/”, LAST);

//Print the redirected URL

lr_message(“redirected address = %s”, lr_eval_string(“{Redirection}”));

return 0;


This is essential to be captured properly during the script creation process since the URL redirection in LoadRunner should work properly without which the scripts will fail to reproduce the real time scenario. Even if there are multiple redirections in an application all those redirects should be captured with proper correlations so that when the script is replayed during execution it replicates the real time business scenario. Each application has a different set of correlation rules that must be applied properly. LoadRunner has pre-built correlation rules that can be used which would make it much more easier and quicker to capture the business scenario.

READ  Software Testing Artifacts - Detailed Guide

Leave a Comment