LoadRunner Run-Time Settings: Additional Attributes

Many times I want to set up Vugen scripts so that I can easily move from one environment to another. Often, the environment being tested if not the same one I script in because of logistics in getting the environments ready. Without getting into the issue of poor configuration management between environments screwing up your scripts – and most LoadRunner scripters know how bad of a problem this is -  I wanted to demonstrate the use of the “Additional Attributes” run-time setting to easily change environments without changing the Vugen code.

You could just as easily create a parameter for the server within the script and switch back and forth between a specific line in the data file, but I think this might be a little bit easier to maintain, especially if you have to share it with other groups or people who come behind you after you are done with the project and may not be “script view” friendly.

1. Create a new attribute in the run-time settings by selecting the “additional attribute” option and put in an argument called “host”, with a value of the server portion of the URL you are testing against. This could be an IP address or the domain name, such as “www.<yoursitenamehere>.com”. I always include a description as well.

2. Put the following code in your vuser_init section:

/* LPCSTR is Microsoft's way of calling a constant char * . */
LPCSTR server;
if (server==NULL){
 lr_error_message("Failed to login. Unknown host.\n");
 return 0;
/*Prepare a string with login information */
lr_message("INFO:>> Using %s server for host environment.", server);
lr_save_string(server, "pURL");

3. Parametrize the URL value hard coded in the script with {pURL}, such as the following example first page request to our test server:

 "Url=/intro.swf", ENDITEM,

4. Do a “find and replace” for the hard coded URL throughout the script.

5. When the time comes to change to a new domain, simply replace the value in the additional attribute run-time setting and never have to touch a line of code.

And optionally….

6. Be prepared for your entire script to break in the new environment anyway, because development forgot to tell you about all the changes they made to the code in the environment under test. Recreate your scripts from scratch and get the project done in spite of the odd against you. :)

Good luck!

What are some other uses for the Additional Attributes run-time setting? Let me know how you use it in the comment section below.

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events

  • raja shekar

    simply superb!!!!!!!!!!!!!!!!!!!!!!!!excellent,wow

  • perftesting

    very helpfull, thanks Mr Scott Moore…

  • Sun

    I was unable to find this option in Performance Center. Do we have this only for the standalone controller.

    I am using HP PC 9.52

  • vinay

    Hi Scott,
    Please kinldy help me, how to edit runtime setting for mutilple scipt in ALM scnerio settings at once…..

  • Thinkquest

    Hi Scott,

    Good article, However is there a way to dynamically change the attribute value directly from the script based on certain condition. So that next time the script runs it will pick up the new changed attribute value.

    Thanks in Advance