首先确认LR11中带有web_reg_save_param_regexp("ParamName=<output parameter name>", "RegExp=regular_expression",[<List of Attributes>,] [<SEARCH FILTERS>,] LAST ); 这个函数。(PS:如果没有需要安装补丁,patch 3);
下面是从loadrunner进阶指南lr11上
学习到的例子,已运行过,能正常使用:
Action()
{
int replyid,i;
web_reg_save_param_regexp(
"ParamName=noreplytopic",
"RegExp=em>0</em>.*\r\n.*tid=(.*)&page.*title",
//.*表示替换任意内容;\r\n表示回车符和换行符
"Ordinal=ALL",
SEARCH_FILTERS,
LAST);
web_url("forum","URL=http://192.168.1.10:88/phpwind85/thread.php?fid=2",LAST);
replyid=lr_paramarr_len("noreplytopic"); //取tid长度
for(i=1;i<=replyid;i++)
{
lr_save_string(lr_paramarr_idx("noreplytopic",i),"temp");
//将tid数组元素存为字符串
web_url("topic","URL=http://192.168.1.10:88/phpwind85/read.php?tid={temp}",LAST);
}
return 0;
}