LoadRunner中多值关联的3种处理方式

点击链接加入QQ群 522720170(免费公开课、视频应有尽有):https://jq.qq.com/?_wv=1027&k=5C08ATe

需求:通过关联取得的ParamName参数可能存在多个值,需要对每个ParamName参数值进行处理

脚本:可通过3种不同的实现方式,将每个参数值作为HTTP请求内容发出

web_reg_save_param("ParamName",

"LB/IC="id":"OutputParameter.",

"RB/IC=","",

"Ord=All",

"Search=Body",

"RelFrameId=1",

LAST);

...

Paramcount=atoi(lr_eval_string("{ParamName_count}")); //参数个数

i=1;

while (i<=Paramcount) {

sprintf(str,"{ParamName_%d}",i);        //生成ParamName_i

//方法一:将变量转为参数,直接在请求中使用参数

lr_save_string(lr_eval_string(str),"Value"); //对每个参数进行处理

web_submit_data("FreeQueryServlet_24",

"Action=http://datasvr01:8081/freequery/FreeQueryServlet",

"Method=POST",

"RecContentType=text/html",

"Referer=http://datasvr01:8081/freequery/js/freequery/businessview/Preview.html",

"Snapshot=t27.inf",

"Mode=HTTP",

ITEMDATA,

"Name=className", "Value=ClientReportService", ENDITEM,

"Name=methodName", "Value=addNewParam", ENDITEM,

"Name=params", "Value=["{ClientID}","OutputParameter.{Value}",""]", ENDITEM,

LAST);

好消息!咨询QQ:2083503238,咨询微信:qiangfans

小强性能测试班19年3月3号开课,年底前报名最高优惠1000元,课程大纲与介绍点击文末【阅读原文】

所有学员享受免费、不限次数、无限重学的权利直到学会为止,拒绝限制次数、缴纳重学费的恶心规矩。

//方法二:通过strcpy、strcat方式组织字符串,通过变量发送请求

strcpy(s,"Value=["{ClientID}","OutputParameter.");

strcat(s,str);

strcat(s,"",""]");

web_submit_data("FreeQueryServlet_24",

"Action=http://datasvr01:8081/freequery/FreeQueryServlet",

"Method=POST",

"RecContentType=text/html",

"Referer=http://datasvr01:8081/freequery/js/freequery/businessview/Preview.html",

"Snapshot=t27.inf",

"Mode=HTTP",

ITEMDATA,

"Name=className", "Value=ClientReportService", ENDITEM,

"Name=methodName", "Value=addNewParam", ENDITEM,

"Name=params", s, ENDITEM,

LAST);

//方法三:通过sprintf格式化输出生成需要的字符串,通过变量发送请求

sprintf(s,"Value=["{ClientID}","OutputParameter.%s",""]",str);

web_submit_data("FreeQueryServlet_24",

"Action=http://datasvr01:8081/freequery/FreeQueryServlet",

"Method=POST",

"RecContentType=text/html",

"Referer=http://datasvr01:8081/freequery/js/freequery/businessview/Preview.html",

"Snapshot=t27.inf",

"Mode=HTTP",

ITEMDATA,

"Name=className", "Value=ClientReportService", ENDITEM,

"Name=methodName", "Value=addNewParam", ENDITEM,

"Name=params", s, ENDITEM,

LAST);

i++;

}

你可能感兴趣的:(LoadRunner中多值关联的3种处理方式)