‘Additional Attributes’ is one of the best features of LoadRunner which gives the option to update the value of the argument without opening the script through the VuGen tool. Many performance testers like this feature of LoadRunner and frequently use in the script, but some of us are not aware of what is ‘Additional Attribute’ about? And how to use it? Hence ignored. In LoadRunner Runtime Settings, additional attributes are used to create a parameter which can also take external input value from controller or performance center. This helps to update the argument value without opening the script through VuGen.
‘Additional Attributes’ tab is available under the ‘General’ category of Runtime settings in VuGen as well as in Controller. The defined attribute reads the value from the runtime settings and passes into the script. Since the normal parameters of the script are defined, declared and edited only through the VuGen, but not from the controller, so additional attribute feature has been introduced to overcome such limitation. As per coding logic, you can pass only a single value in the argument, so you can not pass the list of value (as we do in Parameter Settings). Also, make sure there should be corresponding functions written in VuGen script to read the values.
To understand additional attributes more precisely we will take one example.
Example: Let’s assume, you have 4 instances of a website named ‘myptsite.com’ which are:
The performance regression scenario contains 12 different LoadRunner scripts. For simplicity, let’s assume that all scripts are developed using Web HTTP/HTML protocol. There may or may not be any changes to the scripts but the new release can be deployed on any of the instances listed above.
You can create a parameter <pPort> for port number in the Parameter list as shown in the below figure.
In such a case, you have to update the parameter value every time when the port number gets changed. And hence you have to download the script, open the script in VuGen and update the parameter in all 12 scripts. This could be a time-consuming activity.
Instead of creating a new parameter in the ‘Parameter List’ and update the value every time you have another option.
- Go to Runtime Settings
- Click ‘Additional Attribute’ tab in the left pane
- Click the ‘Add’ button
- Provide ‘Argument Name’, ‘Argument Value’ and ‘Description’ as shown in the below figure
Then use the statement lr_get_attrib_string(“<Argument Name>”) to retrieve the argument value. Here, use lr_get_attrib_string(“aPort”) to retrieve the value ‘8080’.
You can print the value in the output log like this:
lr_output_message(“Port Number: %s”, lr_eval_string(lr_get_attrib_string(“aPort”)));
save it into a parameter via lr_save_string() and access it anywhere in the script using the parameter name. For example,
Now, if the port number changes then you can easily modify the Runtime Settings for all the scripts in the scenario through Performance Center/Controller. Here, you don’t need to open and update the argument value in the individual scripts. If all the scripts use the same Runtime settings, then it is the easiest way. Because you just need to modify the Runtime settings of one script and duplicate it to rest of the scripts.
After updating the argument value:
You may be interested: