LR回放时报错No match found for the requested parameter

LR回放时报错

No match found for the requested parameter "Session". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size


报这个错说明没关联到值,没关联到只有2种可能:要么左右边界错误,要么关联函数位置放错。

脚本如下:

Action()
{

	web_url("WebTours", 
		"URL=http://localhost:1080/WebTours/", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t15.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=http://act.cmcmcdn.com/upload/201507/8afc2fe48db9060fe1bdda2089e1d950.png", ENDITEM, 
		"Url=http://act.cmcmcdn.com/upload/201507/3b491068507d8f85ea7b35d756da7215.png", ENDITEM, 
		LAST);

	lr_think_time(12);

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

	web_submit_data("login.pl_2", 
		"Action=http://localhost:1080/WebTours/login.pl", 
		"Method=POST", 
		"RecContentType=text/html", 
		"Referer=http://localhost:1080/WebTours/nav.pl?in=home", 
		"Snapshot=t17.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=userSession", "Value={Session}", ENDITEM, 
		"Name=username", "Value=jojo", ENDITEM, 
		"Name=password", "Value=bean", ENDITEM, 
		"Name=JSFormSubmit", "Value=on", ENDITEM, 
		"Name=login.x", "Value=42", ENDITEM, 
		"Name=login.y", "Value=8", ENDITEM, 
		LAST);

	web_image("SignOff Button", 
		"Alt=SignOff Button", 
		"Snapshot=t18.inf", 
		LAST);

	return 0;
}

解决方案:

我的脚本中,把关联函数放在了web_submit_data的前面,但是web_submit_data函数是需要使用Session了,所以肯定要在web_submit_data函数之前关联到Session,所以在web_submit_data前面的请求找,看哪个请求的response(响应)中有session的值,有就把关联函数放那个请求前面。找了之后发现web_url("WebTours", 这个请求的response里面有session的值,并且就是web_submit_data函数中所用的session值,所以应该将关联函数放web_url("WebTours",请求之前。

修改后代码如下:

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

	web_url("WebTours", 
		"URL=http://localhost:1080/WebTours/", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t15.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=http://act.cmcmcdn.com/upload/201507/8afc2fe48db9060fe1bdda2089e1d950.png", ENDITEM, 
		"Url=http://act.cmcmcdn.com/upload/201507/3b491068507d8f85ea7b35d756da7215.png", ENDITEM, 
		LAST);

	lr_think_time(12);	

	web_submit_data("login.pl_2", 
		"Action=http://localhost:1080/WebTours/login.pl", 
		"Method=POST", 
		"RecContentType=text/html", 
		"Referer=http://localhost:1080/WebTours/nav.pl?in=home", 
		"Snapshot=t17.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=userSession", "Value={Session}", ENDITEM, 
		"Name=username", "Value=jojo", ENDITEM, 
		"Name=password", "Value=bean", ENDITEM, 
		"Name=JSFormSubmit", "Value=on", ENDITEM, 
		"Name=login.x", "Value=42", ENDITEM, 
		"Name=login.y", "Value=8", ENDITEM, 
		LAST);

	web_image("SignOff Button", 
		"Alt=SignOff Button", 
		"Snapshot=t18.inf", 
		LAST);

	return 0;
}

回放成功!


你可能感兴趣的:(Loadruner)