Parameterize LoadRunner
Scripting enhancement comes after learning the basics of recording and debugging scripts in LoadRunner. In LoadRunner, augmenting scripts means adding some extra capabilities to make scripting simpler, more complete, and more regressive. “Parameterization” is the first stage within the script enhancement section.
For Beginners: If you’re just starting out, you need to understand what parameterization is. The parameterization process involves replacing an input parameter with an encoded value, such as an application URL, username, or password.
Example:
An application’s login page is captured with the credentials USER1 and PASS1. The same credentials are given when the script is run again. You must now replace the hardcoded number, USER1, with a parameter (such as p_userID), if you want to run a test with 5 different users (USER2, USER3, USER4, USER5, and USER6). When the test runs, this argument takes and passes a list of all the specified values.
As a result, the script uses one parameter to pass different input values.
How do you parameterize LoadRunner?
In LoadRunner, parameterization can be done in two different ways:
a) If there is no list of specified parameters:
- The script, please.
- Choose the text value (or value) that you want to parameterize.
- Right-click on the text you chose.
- Choose “Replace by Parameter” from the menu.
- Simply select “Create new parameter”
Figure 01: The step is indicated by a number
6. The ‘Select or Create Parameter’ pop-up will appear; enter a value for the ‘Parameter Name’ and ‘Parameter Type’ fields, then click the ‘OK’ button.
Figure 2: ‘Select or create parameter’ pop-up window
7. You will see another popup asking if you want to replace each instance of the string with the argument. Select ‘Yes’ to replace each instance of the text. This will cause the parameter name to replace the parameterized value.
Figure 3:
8. Select the appropriate option after setting the replacement parameters. The “Find Next” option locates the next occurrence of the text. The “Replace” option only replaces the highlighted text, but the “Replace All” option replaces any occurrence of the text that falls within the chosen range.
Figure 04 – Substitution Scope
b) Visit the script when you have a list of
- Predefined parameters.
- Choose the text value (or value) that you want to parameterize.
- Right-click on the text you chose.
- Choose “Replace by Parameter” from the menu.
- Select the appropriate parameter from the list under “Parameter list…”.
Image 05
6. “Do you want to replace all occurrences of the string with the parameter?” asks a popup window. Select ‘Yes’ to replace each instance of the text. This will cause the parameter name to replace the parameterized value.
Image 06
7. Select the appropriate option after setting the replacement parameters. The “Find Next” option locates the next occurrence of the text. The “Replace” option only replaces the highlighted text, but the “Replace All” option replaces any occurrence of the text that falls within the chosen range.
Image 07
How to reset the parameter in LoadRunner to its original value?
- Right-click on the parameter you want to restore.
- Restore the original value by clicking.
Image 08