loadrunner拼接关联数组的元素
int arrSize=0;
int index=1;
int len=0;
char arryStartString[1024]="";
web_set_max_html_param_len("999999");
//input type="hidden" name="authenticityToken" value="b8aca4150168a1b09507e6b7c7b36c8327de762e">
//将所有的策略信息中的data_compare-check获取出来
//<span class="constract" data-compare-check="647481911801428F95D3AC7EDCA73918" data-compare="647481911801428F95D3AC7EDCA73918">
web_reg_save_param_ex("ParamName=data-compare-check",
"LB=<span class=\"constract\" data-compare-check=\"",
"RB=\" data-compare",
"Ordinal=ALL",
SEARCH_FILTERS,
LAST );
web_add_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
web_add_header("Accept-Charset", "iso-8859-1,*,utf-8");
web_add_header("Accept-Encoding", "gzip,deflate");
web_add_header("Accept-Language", "en-us,en");
web_add_auto_header("User-Agent", "Mozilla/5.0 (Windows NT 5.1)
AppleWebKit/535.4 (KHTML, like Gecko) Chrome/13.0.782.41
Safari/535.4");
web_custom_request("策略列表",
"URL=http://192.168.101.104:9000/strategys/strategylist",
"Method=GET",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
//arrSize=lr_paramarr_len("data-compare-check");
srand(time(NULL));
for(index;index<6;index++){
//lr_save_string(lr_paramarr_idx("data-compare-check", index),"data_string");
//lr_paramarr_random("outFlightVal");
lr_save_string(lr_paramarr_random("data-compare-check"),"data_string");
//拼凑如下类似的脚本
//idArray%5B%5D=K0000024&idArray%5B%5D=222E0CD6AE5342B596670834CEE6FA4F&idArray%5B%5D=647481911801428F95D3AC7EDCA73918&
//idArray%5B%5D=72ED1B2B829C49E9A9B581A30FCDF057&idArray%5B%5D=C781810735904308800B0E55F1BD2680
strcat(arryStartString,"idArray%5B%5D=");
strcat(arryStartString,lr_eval_string("{data_string}"));
strcat(arryStartString,"&");
}
len=strlen(arryStartString);
arryStartString[len-1]='\0';
//idArray%5B%5D=5FA68737E1404709BB1F638309985366&idArray%5B%5D=C781810735904308800B0E55F1BD2680&
//idArray%5B%5D=54156134E0824DDB8E3F26AA3529A136&idArray%5B%5D=K0000024&idArray%5B%5D=647481911801428F95D3AC7EDCA73918
lr_save_string(arryStartString,"idArrayString");
lr_output_message ("arrStartString=%s",lr_eval_string("{idArrayString}"));
return 0;