Loadrunner关联的内容是数组的解决办法
/广告:普遍真理实验室http://commonright.lingd.net
1、在action开头定义要用带的变量
int istemp=0;//控制循环的游标
int count=0;//存储关联出来的参数数量一般在关联参数后面加上_count就可以获得namejpeg_count
char temp[255];//存储生成的关联参数namejepg_1,namejepg_2
char temptolr[255];//存储temp内部存储的字符串//广告:普遍真理实验室http://commonright.lingd.net
2、获取关联数组
web_reg_save_param("namejpeg","LB=img1.jike.com:82/get?name=","RB=\"","ORD=ALL","SEARCH=BODY",LAST);//广告:普遍真理实验室http://commonright.lingd.net
3、计算关联数组的个数
//获取关联出的字符串数组的大小,通过c语言的atoi函数将字符串转换成整形变量
//namejpeg_count是关联函数自己定义的不是我们自己声明的因此这里要用("{namejpeg_count}")调用
count = atoi(lr_eval_string("{namejpeg_count}"));//广告:普遍真理实验室http://commonright.lingd.net
4、获取各个关联数组变量
sprintf(temp,"{namejpeg_%d}",istemp+1);//每次循环应用的不同的namejpeg_X
//广告:普遍真理实验室http://commonright.lingd.net
sprintf(temptolr,"%s",lr_eval_string(temp));//namejpeg_X存储的关联字符串存入temptolr变量中。
// 由于temp是在action开头自己声明的,因此 不需要应用“{}”调用
lr_save_string(temptolr,"tempname");//C的变量不能直接在LR的API里调用,所以必须用lr_save_string进行转换。下面应用tempname就可以了
web_url("get",
"URL=http://img1.jike.com:82/get?name={tempname}",
"Resource=1",
"RecContentType=application/octet-stream",
"Referer=http://image.jike.com/so?q={searchparam}",
"Snapshot=t26.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
5、这个脚本是录制即刻图片搜索的脚本action函数整体脚本如下:
Action()
{
//---init//广告:普遍真理实验室http://commonright.lingd.net
int istemp=0;//控制循环的游标
int count=0;//存储关联出来的参数数量一般在关联参数后面加上_count就可以获得namejpeg_count
char temp[255];//存储生成的关联参数namejepg_1,namejepg_2
char temptolr[255];//存储temp内部存储的字符串
web_url("index.php",
"URL=http://image.jike.com/index.php",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTTP",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_concurrent_start(NULL);
web_url("helpers-min.js",
"URL=http://image.jike.com/js/helpers-min.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://image.jike.com/index.php",
"Snapshot=t2.inf",
LAST);
web_url("homeImg.css",
"URL=http://image.jike.com/style/homeImg.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://image.jike.com/index.php",
"Snapshot=t3.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_url("baseNew.css",
"URL=http://image.jike.com/style/baseNew.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://image.jike.com/index.php",
"Snapshot=t4.inf",
LAST);
web_url("logoImg.gif",
"URL=http://image.jike.com/images/logo/logoImg.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://image.jike.com/index.php",
"Snapshot=t5.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_url("14",
"URL=http://imagebg.jike.com/recommendPicture/img/GetImg/rpid/14",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://image.jike.com/index.php",
"Snapshot=t7.inf",
LAST);
web_url("16",
"URL=http://imagebg.jike.com/recommendPicture/img/GetImg/rpid/16",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://image.jike.com/index.php",
"Snapshot=t8.inf",
LAST);
web_url("10",
"URL=http://imagebg.jike.com/recommendPicture/img/GetImg/rpid/10",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://image.jike.com/index.php",
"Snapshot=t9.inf",
LAST);
web_url("12",
"URL=http://imagebg.jike.com/recommendPicture/img/GetImg/rpid/12",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://image.jike.com/index.php",
"Snapshot=t10.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_url("13",
"URL=http://imagebg.jike.com/recommendPicture/img/GetImg/rpid/13",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://image.jike.com/index.php",
"Snapshot=t11.inf",
LAST);
web_url("15",
"URL=http://imagebg.jike.com/recommendPicture/img/GetImg/rpid/15",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://image.jike.com/index.php",
"Snapshot=t12.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_concurrent_end(NULL);
web_url("BgBase.gif",
"URL=http://image.jike.com/images/bg/BgBase.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://image.jike.com/index.php",
"Snapshot=t6.inf",
LAST);
web_url("favicon.ico",
"URL=http://image.jike.com/favicon.ico",
"Resource=1",
"RecContentType=image/x-icon",
"Referer=",
"Snapshot=t13.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
lr_start_transaction("0-search");
web_reg_save_param("namejpeg","LB=img1.jike.com:82/get?name=","RB=\"","ORD=ALL","SEARCH=BODY",LAST);
web_submit_data("so",
"Action=http://image.jike.com/so",
"Method=GET",
"EncType=",
"RecContentType=text/html",
"Referer=http://image.jike.com/index.php",
"Snapshot=t14.inf",
"Mode=HTTP",
ITEMDATA,
"Name=q", "Value={searchparam}", ENDITEM,
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_concurrent_start(NULL);
web_url("ie6listPage.css",
"URL=http://image.jike.com/style/ie6listPage.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://image.jike.com/so?q={searchparam}",
"Snapshot=t15.inf",
LAST);
web_url("ie6ImgBD.css",
"URL=http://image.jike.com/style/ie6ImgBD.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://image.jike.com/so?q={searchparam}",
"Snapshot=t16.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_url("ie6baseNew.css",
"URL=http://image.jike.com/style/ie6baseNew.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://image.jike.com/so?q={searchparam}",
"Snapshot=t17.inf",
LAST);
web_url("jike-autoComplete-min.js",
"URL=http://image.jike.com/js/jike-autoComplete-min.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://image.jike.com/so?q={searchparam}",
"Snapshot=t18.inf",
LAST);
web_url("jike-log-min.js",
"URL=http://image.jike.com/js/jike-log-min.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://image.jike.com/so?q={searchparam}",
"Snapshot=t19.inf",
LAST);//广告:普遍真理实验室http://commonright.lingd.net
web_url("ajax-min.js",
"URL=http://image.jike.com/js/ajax-min.js",
"Resource=1",