LoadRunner - Copying Parameters Between Scripts
Congratulations on wanting to use the same parameters for multiple scripts. This helps speed up the script development process and makes your scripts more consistent and predictable.
Short Explanation
- Create original script that has numerous parameters defined.
- Record and close a new script.
- From the original script, copy the .prm file to the new script's directory.
- Rename the .prm file to the name of the new script.
- All done!
Long Explanation
Has This Ever Happened to You?
- Created a script that has numerous parameters defined.
- Recorded another script and wanted to use the same parameters.
- Embarked on recreating the parameters in the new script.
If you have a lot of parameters and/or scripts, this process can be slow, painful, and potentially error prone. What happens if you forget a setting for one of the parameters? This inconsistency will drive you crazy. How can we ensure the same parameter list for our scripts?
What We Want to Do
- Create our first script with all required parameters added.
- Create a new script.
- Get the parameters from the first script and add them to the new script. Do this without manually entering in all the parameter details.
Agree on a naming convention for your parameters. Parameter names should reflect the information they contain. I like to use camel-case prepended with a 'p' (for parameter).
Step 1
Create the inital script and add all required parameters (named appropriately). Test the script and make sure it works as expected.
Step 2
Create a new script. Save and close the new script.
Step 3
Open two 'Windows Explorer' windows and navigate to the two scripts.
Copy the original script's .prm file and data files and paste into the new script's directory.
Rename the .prm to be the same name as the script.
Step 4
Open the new script and you will now see all the parameters. Add/remove parameters as needed.
Future Considerations
Possible Changes
- Create a common 'data' directory to store all the parameter files that are used by multiple scripts. Doing this will eliminate duplicate parameter files and promote modular script design.
- Use relative file paths instead of absolute file paths.
- Create a common .prm file that all scripts use. This can be awkward if too many parameters.
- Create different common parameter files. Use these as templates and adjust appropriately from script to script. Be careful not to change the basic parameters. If you do, you may want to change for all your existing scripts.
Conclusion
We can now copy parameters from one script to another without having to enter all the parameter details manually. This should save you some time and improve the consistency in your scripts.
We also see that the script's parameter definitions exist in a .prm file that can be viewed and manipulated as plain text.
Reader Comments