The parameter array provides a mechanism for centralizing a class of parameters, where several functions that are built into LR are: Lr_paramarr_idx (), Lr_paramarr_len (), Lr_paramarr_random ()
At the same time, the parameter array must satisfy two conditions: the ① parameter must be preceded by the same name, followed by an underscore and the number of sequential assignment; The ② parameter array must have a parameter named _count to record the length of the number.
eg
Lr_save_string ("www.google.com", "website_1");
Lr_save_string ("www.baidu.com", "website_2");
Lr_save_string ("www.163.com", "website_3");
Lr_save_string ("www.sina.com.cn", "website_4");
Lr_save_string ("4", "Website_count");
This script creates an array of arguments named website, followed by a function to manipulate the array of arguments:
Char *siteval;
Siteval=lr_paramarr_idx ("website", 2)---------- output: www.baidu.com
Char *siteval
Siteval=lr_paramarr_random ("website")--------- output: Random values in the website parameter array
If you need to facilitate all of the contents of the entire parameter array, you can do so by:
int Arrid
For (Arrid=1;arrid<=lr_paramarr_len ("website"); i++)
{
Lr_output_message (Lr_paramarr_idx ("website", Arrid));
}
The following are examples of help manuals:
This is example shows how to get the last value from a parameter array.
int arrsize;
char * FLIGHTVAL;
Web_reg_save_param ("Outflightval",
"Lb=outboundflight value=", "rb=>",
"Ord=all",
"Savelen=18",
last);
Web_submit_form ("reservations.pl",
"Snapshot=t4.inf",
ItemData,
"Name=depart", "Value=london", Enditem,
"Name=departdate", "value=11/20/2003", Enditem,
"Name=arrive", "Value=new York", Enditem,
"Name=returndate", "value=11/21/2003", Enditem,
"Name=numpassengers", "value=1", Enditem,
"Name=roundtrip", "value=<off>", Enditem,
"Name=seatpref", "Value=none", Enditem,
"Name=seattype", "Value=coach", Enditem,
"Name=findflights.x", "value=83", Enditem,
"Name=findflights.y", "value=16", Enditem,
last);
/*
The result of the Web_reg_save_param has been called before the Web_submit_form is:
Notify:saving Parameter "Outflightval_1 = 230;378;11/20/2003"
Notify:saving Parameter "outflightval_2 = 231;337;11/20/2003"
Notify:saving Parameter "outflightval_3 = 232;357;11/20/2003"
Notify:saving Parameter "outflightval_4 = 233;309;11/20/2003"
Notify:saving Parameter "Outflightval_count = 4"
*/
Arrsize = Lr_paramarr_len("Outflightval");
Flightval = lr_paramarr_idx("Outflightval", arrsize);
Flightval contains the value "233;309;11/20/2003".
LoadRunner parameter array