LoadRunner中的参数化问题
下面是我录制http://www.fjgsgl.com/网站进行费率查询的代码(已经进行修改过):/*这段代码可以正确执行,可以循环,可以写入文件,但数组使用和参数化估计有问题,结果全是N/A*/Action()
{
int leon1;
char leon;
char zhan={"2101","2102","2103"};
int i,j;
web_url("www.fjgsgl.com",
"URL=http://www.fjgsgl.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/focus.swf", ENDITEM,
"Url=/files/2009/60.jpg", "Referer=http://www.fjgsgl.com/focus.swf", ENDITEM,
"Url=/Files/2009/DSC00600.JPG", "Referer=http://www.fjgsgl.com/focus.swf", ENDITEM,
"Url=/main.files/lihoulin400x215.jpg", "Referer=http://www.fjgsgl.com/focus.swf", ENDITEM,
"Url=/Files/kxfzg090328.jpg", "Referer=http://www.fjgsgl.com/focus.swf", ENDITEM,
"Url=/Files/slogan1024.jpg", "Referer=http://www.fjgsgl.com/focus.swf", ENDITEM,
"Url=/Files/W020080103316475157468.jpg", "Referer=http://www.fjgsgl.com/focus.swf", ENDITEM,
"Url=/Files/2009092510450321457.jpg", ENDITEM,
"Url=/Files/2009/2009071317245538182.jpg", ENDITEM,
"Url=/main.files/105x75.jpg", ENDITEM,
"Url=/main.files/fqgs001.jpg", ENDITEM,
"Url=/main.files/fqgs002.gif", ENDITEM,
"Url=/Foosun_Plus/Ads/CreateJs/RightBottom.js", ENDITEM,
LAST);
web_url("show.asp",
"URL=http://www.fjgsgl.com/Foosun_Plus/Ads/show.asp?Location=5",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.fjgsgl.com/",
"Mode=HTML",
LAST);
leon1=(int)fopen("D:\\huoyanming.txt","at+");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
web_reg_save_param("leon","LB=距离为","RB=公里",LAST);
web_submit_data("zfbz.asp",
"Action=http://www.fjgsgl.com/zfbz.asp?zf=submit",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.fjgsgl.com/zfbz.asp",
"Snapshot=t2.inf",
"Mode=HTML",
ITEMDATA,
/*下面两行是表单的两个选项(出发站和目的站),我想用一个数组中的元素给他们赋值,我完全是新手,不知道下面的做法对不对*/
"Name=names1", "Value={zhan}", ENDITEM,
"Name=names2", "Value={zhan}", ENDITEM,
"Name=B1", "Value=查询", ENDITEM,
LAST);
fprintf(leon1, "距离为%s公里\n",lr_eval_string("{leon}"));
}
}
fclose(leon1);
return 0;
}我运行的结果是文件中的9条数据都是“距离为N/A公里”,而在参数化之前是可以正确显示距离的。请各位帮忙看看是哪里的问题?不胜感激
[ 本帖最后由 pengpeng5047 于 2009-11-2 23:29 编辑 ] 通过for循环,用数组中的元素给变量赋值,达到参数化的目的好像不对吧。
你可以将参数保存在.txt文件里,然后在脚本里面选中需要参数化的值,右键菜单-->Replace with a parameter.
Parameter tpye为file,点击Properties,加载.txt参数文件及设置参数化策略。就可以了。 谢谢
页:
[1]