This is a simple question - what is LoadRunner parameter?
I've reread LoadRunner VuGen User's Guide v9, trying to find the exact definition of LoadRunner parameter. That's strange, but LoadRunner Help does not contain the exact answer on this question.
In this article, I will answer basic questions, connected to LoadRunner parameters.
I think, LR beginners should study this article carefully :)
So, I recommend to read it, if you want to know:
- the definition of LoadRunner parameter
- LoadRunner parameter functions
- how to create parameter in LoadRunner VuGen script
- which types of LoadRunner parameter are available
- how LoadRunner processes parameters - gets and sets their values
- other key concepts, connected to LR parameters
I've recorded Web (HTTP/HTML) simple script on Web Tours demo web application. There are two first steps:
Please, notice that we use the following hard-coded username & password - jojo and jojo:
- "Name=username", "Value=jojo", ENDITEM,
- "Name=password", "Value=bean", ENDITEM,
What should we do, if we want to execute our script sequentially for different users, for example for jojo/bean, then for bob/lcdm, dm/psswrd, and so on?
There are several solutions:
- The simplest one is to record our script for each user.
In this case, our pseudocode will look like:
- Login as jojo/bean
- Perform other actions under jojo/bean
- Login as bob/lcdm
- Perform other actions under bob/lcdm
- Login as dm/psswrd
- Perform other actions under dm/psswrd
-
- so on...
- We can remake our code:
- Loop - perform next actions for each user name and password
- Read user name and password into {UserName} and {Password} variables
- Login as {UserName} and {Password}
- Perform other actions under {UserName} and {Password}
I do not use hard-coded values (jojo/bean, bob/lcdm, dm/psswrd, and so on). Instead, we use special variables - {UserName} and {Password}. They are parameters.
The source code will look like:
So, now we can answer:
Question: What is LoadRunner parameter?
The simple answer is:
LoadRunner parameter is a special variable.
Note: We will investigate parameters and I will provide more exact definition later.
Since LoadRunner parameter is a variable, then I compare it with standard stack-based variable from C language (for example - int i).
- Declaration
To declare stack variable you can just write:This means, that name of variable is 'i', and its type is int. It's easy, isn't it?- int i;
To declare LoadRunner parameter you have to:- select string, to be replaced with a parameter
- right-click on the selected text
- 'Replace with a parameter'
'Select or Create Parameter' dialog opens. - Here, you can enter name of your parameter:
Note, that you can see an original value as well ('jojo' in our case). - Specify type of parameter
Parameter type is determined by the source of parameter data:
Once you specified name and type of parameter, you declared LoadRunner parameter.
The above declaration of parameter uses GUI ('Select or Create Parameter' dialog).
This is not the only approach. We can declare parameter and assign value with lr_save_ functions (lr_save_string, lr_save_int, lr_save_searched_string, lr_save_var, and lr_save_datetime).
See these examples:
- lr_save_string function
- lr_save_string("abCDEfgID", "prmProductID");
- lr_output_message("ID is: %s", lr_eval_string("{prmProductID}"));
Here, I define new parameter ("prmProductID") and assign a value ("abCDEfgID") to it. So, the parameter contains this value.
To make sure that the parameter contains correct value, please see the result of execution:
Please, note that we can write analogous code using a stack variable:- char *pszProductID = "abCDEfgID";
- lr_output_message("ID is: %s", pszProductID);
The result will be the same:
So, as you see, LR parameter is similar to standard variables. - lr_save_int function
- lr_save_int(144, "prmCounter");
- lr_output_message("Counter: %s", lr_eval_string("{prmCounter}"));
- lr_save_int(-18, "prmCounter");
- lr_output_message("Counter: %s", lr_eval_string("{prmCounter}"));
Result is:
Again, we can write analogous code using stack variables:- int i;
- char pszCounter[12];
- i = 144;
- itoa(i, pszCounter, 10);
- lr_output_message("Counter: %s", pszCounter);
- i = -18;
- itoa(i, pszCounter, 10);
- lr_output_message("Counter: %s", pszCounter);
The result will be the same too:
- int i;
So, now you can ask:
Question: What's the difference between LR parameter and stack-based variables?
// That is the question (C) W. Shakespeare :)
OK, I will answer - the LoadRunner parameters simplify:
- Working with memory
That is, you don't have to know, how many bytes allocate for a current value of parameter.
You just use lr_save_string (for example) function, and LR allocates required number automatically. - Working with data sources
For example, you can indicate, that values of parameters will be stored in a file:
In this case, you don't have to write additional code for file processing. LoadRunner takes all routine procedures upon himself. For example - when and how update values from file, what is the current delimiter, and so on.
Actually, these features (working with memory and data sources) are very comfortable from user's side. That's why LoadRunner parameter is used so extensively.
My article, describing LoadRunner parameter and parameterization, is up.
I hope, it was helpful :) Please, let me know...
In the next part, I will describe operations you can perform with parameters.
After that, I will explain - how LoadRunner parameterization is connected with correlation (this question was asked by Anonymous in his comment).
And, as usual, I'm waiting for your opinions.
If you have some questions or doubts - feel free to ask me.
--
Yours faithfully,
Dmitry Motevich, living in LoadRunner-city :)
Related articles:
- How to perform basic operations on LoadRunner parameters?
- Using parameters in Loadrunner VuGen script
- Using Correlation in LoadRunner scripts - visual tutorial
- How to get LoadRunner iteration number - using LoadRunner parameter?
36 comments:
Hi,
Thanks for the Article. Another tutorial describing the usage of various options available for the Paramters i.e the following will be helpful.
a. Next row selection(sequential,Unique)
and
b.update method(i.e each iteration,once)
and
c.Option for When Out of Values( i.e - Continue in Cyclic manner,Abort Vuser,continue with LAST value)
An example of how these will be used when there is only one single user and when there are multiple users will be helpful.
Hi Dmitry,
What I want is to paramaterize my script using the parameterization feature of LR but don't want to hard code the location of the dat files.I want the code to be portable. Is there a way to relatively locate a dat file during runtime?
Thank you very much. All your tutorials are very useful. Can you post more about how each parameter type(especially the iteration number) is used?
Thanks a load.
Can you please post an example of using the web_eval_java_script function?
Thanks but could u please let me know the purpose of having columns in datafile. IF i have login nad password in same file, how can i use them in my script. explain with eg
1.what is caching? when will we use caching?
2. How to report the scenario analysis. Give me the brief explanation?
1.what is caching? when will we use caching?
2. How to report the scenario analysis. Give me the brief explanation?
its a great help for entry level ppl,dude you are the best ,thanx and i really really appreciate the way you like to share your in depth knowloadge
once again thnx buddy
Simple and easy to understand! thanks a ton!
Hi
I found out your blog site today and was going through your articles. They have been beautifully written and explained well. I have been working with automation tools (WR,QTP and LR) since last 4-5 years, but reading your blog made many things easier for me to understand and keep in mind. Thanks and keep sharing the knowledge.
Thanks. This is the most practical explanatiion of the loaddrunner i have ever come across. Please keep it up.
2Anonymouses:
Thank for reading my blog!
I will continue posting interesting articles
hi thanks for sharing your knowledge in such a nice way.
how can we run script without installing qtp ?
2 lucky:
What scripts do you want to run without QTP? Maybe, JavaScript, Perl scripts or Python scripts? :)
Please, specify...
Hi, Thanks for posting such a good article on oarametrization.
I am facing a little poroblem in parametrization. I am using 2 ranges of numeric strings i.e. Start Range and End Range. I am using both as parameter and data table has values against both of these parameters. I have selected to update values only once and both ranges should be unique in each iteration but when script replay the old values will be retrieved by script. So how can I handle this.
Second thing is that how can I increment in these 2 values ?
2 Kashif:
I didn't understand your problem with dates... Please, explain in details, if possible.
Any examples and screenshots will help me to help you :)
finally i found a place where i can interact effectively, I have been trying for random parameterization within a single iteration ,i tried the use random for each occurance which is doesnt quite well work with what i am doing.. goal is to drive a different values within each iteration. any suggestion is welcome.
thanks for the help in advance.
2sdip:
I cannot understand what you ask.
If you want to get an answer, please, formulate a detail question.
no of Iterations specified in the run time settings is 1(one) ,
In the script i am iterating multiple(4) times(eg:adding 4 locations) ,I want to add a unique location for each iteration .
i tried specifying unique/random for each occurrance , I want to use next row.
I hope this helps. please let me know.thanks
no of Iterations specified in the run time settings is 1(one) ,
In the script i am iterating multiple(4) times(eg:adding 4 locations) ,I want to add a unique location for each iteration .
i tried specifying unique/random for each occurrance , I want to use next row.
I hope this helps. please let me know.thanks
2sdip:
I cannot answer your question until you specify details...
Please, understand me:
- I know nothing about your application
- I've never seen your LR script
Which "unique location" do you mean?
Hi
I am trying to create a script that will run forever (3 days). I have a dat file with SSN (social security number) for customers. I have choosen to select a new for each iteration. My problem is that I have serveral user running same script, and i only want to use each ssn once. (not once for each user) With the option each iteration i excepted it to used only once, but since i have 200 users, its been used 200 times. What can i do? Thanks for any answer
As I understood, you have to select
"Use a new value for each occurrence of the parameter" setting of SSN parameter.
But i think that is also wrong since the ssn is posted serveral times during once iteration. I need to keep the same customer during the whole script. I understand chosing that option will make it change during the iteration. Maybe i am wrong how it works? Thanks for your answer
2 Mr. Anonymous:
Your requirements are so changeable...
If you "need to keep the same customer during the whole script", then use "Once" option for SSN parameter.
P.S. I would recommend to formulate your question in details... It's so difficult to read them and understand what you want.
Thanks again. Sorry for the bad question :-)
Scenario: 200 simulationous users filling out loan applications for idefently many customers.
One loan application for each customer.
The SSN is put in serveral times during one iteration. For one iteration it need to keep the same, but should never be used again for that user or any other user after that iteration is done.
I will try "once" option now. It sounds incorrect but i guess it depend what that they mean with "once"
Thanks
Tried "once" options now and sadly it dont works. It looks like it works like "each iteration", but it will not start at det beginning after i am out of ssn.
After some more testing i found out that the correct option is "each iteration" but you also need to select unique in the drop down over that selection.
Thanks
Hi,
I have been doing Manual Testing for long,just 1 week back i started studying Load Runner through User Guide and Various sites..I am speechless to appreciate your efforts.............They are absolutely fantastic..........I was yearning for something like this.This is coming directly from my heart....I am really happy ,for a beginner like me it's a boon and u have cleared most of the concepts of scripting and paramterization.Thank u sooo much...
Its like a virtual class and tutorials are also fantastic
...May God Bless U ! :)
2Anonymous,
Thank you for your words :)
HI Dimitry,
I am having an issue with Parameterization. I have selected in the following way for parameterizing some data: "Unique", "Update on each iteration", "Abort when out of values", "Automatically allocate block size" and there are around 12000 records in .dat file. I have assigned 12 users for this script, and getting error "Insufficient records" during the load test.
Satish,
I explained this error and its cause here:
LoadRunner VIDEO - Parameters part3 ('Select next row' = 'Unique')
Hi, I have a typical requirement. I have three dropdowns on my web based app. The values in second dropdown are dependent on selection in first dropdown and so for the third. I need to select the values in each dropdown sequentially in each iteration. Am not sure how to recognize the dropdowns and select the values. The only step that LR reads is the submit button click after selecting the dropdowns, where it sends the selected values in the url to the server. Can you please help?
It is true that there is not particular definition for Parameter, but your example helps a lot. Thanks and GOD bless you.
@Anonymous (December 11, 2008),
It seems, you confuse functional testing (QTP) and load testing (LR).
LoadRunner does not record UI objects. It records a client-server traffic.
I think, you should use QTP for you task
Post a Comment