Configuring target hostname in Loadrunner tests

Have more than one test-systems makes it imperative to make the target hostname parametric in the Loadrunner scripts, particularly if it is intended to run the Loadrunner script from time to time on different environments.

First, create a new Additional Attribute for the target hostname in VuGen (press F4, then select Additional Attributes). Specify a default host name. The hostname value will be later overridden during runtime configuration, so no modification in the script itself will be necessary.

Defining Additional Attributes in Virtual User Generator

Then read the value of the Additional Attribute programmatically in the script play lucky ladies blackjack online and store it in a parameter.  This makes it easy to use the hostname in the web_url() calls. (Dealing with the configuration should be done practically in vuser_init(), as it should be performed only once during a Virtual User lifecycle. )


  // read the value of the 'host' attribute and store it as a parameter (p_host)
  lr_save_string(lr_get_attrib_string("host"), "p_host");
  return 0;

In your user actions use the p_host parameter in the web_url() requests conveniently:


  web_reg_find("Text=<div class=\"homepage-main\"", LAST);


  web_url("Access home page",

  lr_end_transaction("Homepage", LR_AUTO);

  return 0;


Unfortunately in Performance Center’s Load configuration the Additional Attributes can not be overridden in the Performance Center’s Runtime settings.
The good news is that there is an option to specify command line parameters (for all scripts in a load test, or per scripts individually). The command line arguments override the values specified in the Additional Attributes dialog, so you can specify the desired target host, if it is differs from the default. This way there is no need to modify the saved script, just the Load test configuration.

Here is where the command line argument can be specified:

Doing so the script will pick up the target hostname from the runtime configuration and use it in the course of testing.

Leave a Reply

Your email address will not be published. Required fields are marked *