LoadRunner中web_reg_find的SaveCount变量一直为0解决办法

最近把以前学习过的LoadRunner翻出来又从新学习了一下,过程当中出现web_reg_find的SaveCount计数一直为0的现象。前期脚本以下:html

Login()
{

	web_reg_save_param("Session",
					   "LB=name=userSession value=",
					   "RB=>",
					   LAST);

	web_reg_find("Text=Web Tours reservation pages",
			 "SaveCount=nameCount",
			 "Search=Body",
			 LAST);

	web_url("WebTours", 
		"URL=http://127.0.0.1:1080/WebTours/", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t1.inf", 
		"Mode=HTML", 
		LAST);

	lr_start_transaction("Login");

	web_submit_data("login.pl", 
		"Action=http://127.0.0.1:1080/WebTours/login.pl", 
		"Method=POST", 
		"TargetFrame=", 
		"RecContentType=text/html", 
		"Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", 
		"Snapshot=t2.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=userSession", "Value={Session}", ENDITEM, 
		"Name=username", "Value=test1", ENDITEM, 
		"Name=password", "Value=111111", ENDITEM, 
		"Name=JSFormSubmit", "Value=on", ENDITEM, 
		"Name=login.x", "Value=62", ENDITEM, 
		"Name=login.y", "Value=10", ENDITEM, 
		LAST);

	lr_end_transaction("Login",LR_AUTO);

	lr_output_message("username count is %s",lr_eval_string("{nameCount}"));

	return 0;
}

输出的结果老是显示“Login.c(45): username count is 0”,后来想起web_reg_find函数要放在请求发送前面,而后就修改了一下web_reg_find的位置:web

Login()
{

	web_reg_save_param("Session",
					   "LB=name=userSession value=",
					   "RB=>",
					   LAST);

	web_url("WebTours", 
		"URL=http://127.0.0.1:1080/WebTours/", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t1.inf", 
		"Mode=HTML", 
		LAST);

	lr_start_transaction("Login");

	web_reg_find("Text=Web Tours reservation pages",
			 "SaveCount=nameCount",
			 "Search=Body",
			 LAST);

	web_submit_data("login.pl", 
		"Action=http://127.0.0.1:1080/WebTours/login.pl", 
		"Method=POST", 
		"TargetFrame=", 
		"RecContentType=text/html", 
		"Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", 
		"Snapshot=t2.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=userSession", "Value={Session}", ENDITEM, 
		"Name=username", "Value=test1", ENDITEM, 
		"Name=password", "Value=111111", ENDITEM, 
		"Name=JSFormSubmit", "Value=on", ENDITEM, 
		"Name=login.x", "Value=62", ENDITEM, 
		"Name=login.y", "Value=10", ENDITEM, 
		LAST);

	lr_end_transaction("Login",LR_AUTO);

	lr_output_message("username count is %s",lr_eval_string("{nameCount}"));

	return 0;
}

再次执行,显示结果符合预期。特别再次记录下。按书中所说,web_reg_find必定要放在实际请求提交以前,中间不能隔着其余东西。函数

相关文章
相关标签/搜索