1. 程式人生 > >LoadRunner對phpwind進行登入引數化指令碼編寫

LoadRunner對phpwind進行登入引數化指令碼編寫

Action()
{
	lr_start_transaction("HomePage");////////事務開始,統計某一操作的響應時間

	web_url("phpwind", 
		"URL=http://localhost:81/phpwind/", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t41.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=js/lang/zh_cn.js", ENDITEM, 
		"Url=images/wind/bg.jpg", ENDITEM, 
		"Url=images/wind/topbar.png", ENDITEM, 
		"Url=images/button.png", ENDITEM, 
		"Url=images/wind/navA.png?20141218", ENDITEM, 
		"Url=images/select_arrow.gif", ENDITEM, 
		"Url=images/del.png", ENDITEM, 
		"Url=images/wind/searchA.png", ENDITEM, 
		"Url=images/wind/search_btn.png", ENDITEM, 
		"Url=images/wind/h.png", ENDITEM, 
		"Url=images/wind/down.png", ENDITEM, 
		"Url=images/wind/old.gif", ENDITEM, 
		"Url=images/wind/colon.png", ENDITEM, 
		"Url=images/wind/new.gif", ENDITEM, 
		"Url=images/pwicon/top.png", ENDITEM, 
		"Url=images/wind/search_input.png", ENDITEM, 
		LAST);

	
	lr_end_transaction("HomePage", LR_AUTO);////////事務結束


	web_reg_save_param("verifyLogin",//////////關聯函式,手動關聯
		"LB=name=\"verify\" value=\"",
		"RB=\" />",
		LAST);

	web_url("立即登入", 
		"URL=http://localhost:81/phpwind/login.php", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=http://localhost:81/phpwind/", 
		"Snapshot=t42.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=images/wind/bg.jpg", ENDITEM, 
		"Url=../favicon.ico", "Referer=", ENDITEM, 
		LAST);

    //////插入結合點,等待併發登入,統計併發登入的事務響應時間時,應該放在事務前面,不要計算等待的時間
	lr_rendezvous("Login");
	
	lr_start_transaction("Login");

	web_reg_find("SaveCount=LoginCount",//檢查點,檢查web伺服器返回的網頁是否正確
		"Text=退出",
		LAST);

	web_submit_data("login.php", 
		"Action=http://localhost:81/phpwind/login.php?", 
		"Method=POST", 
		"TargetFrame=", 
		"RecContentType=text/html", 
		"Referer=http://localhost:81/phpwind/login.php", 
		"Snapshot=t43.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=forward", "Value=", ENDITEM, 
		"Name=jumpurl", "Value=http://localhost:81/phpwind/", ENDITEM, 
		"Name=step", "Value=2", ENDITEM, 
		"Name=verify", "Value={verifyLogin}", ENDITEM, 
		"Name=lgt", "Value=0", ENDITEM, 
		"Name=pwuser", "Value={username}", ENDITEM, 
		"Name=pwpwd", "Value={password}", ENDITEM, 
		"Name=hideid", "Value=0", ENDITEM, 
		"Name=submit", "Value=", ENDITEM, 
		EXTRARES, 
		"Url=images/wind/bg.jpg", "Referer=http://localhost:81/phpwind/login.php?", ENDITEM, 
		"Url=images/register/regright_big.png", "Referer=http://localhost:81/phpwind/login.php?", ENDITEM, 
		"Url=js/lang/zh_cn.js", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/down.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/g/facebg_a.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/topbar.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/navA.png?20141218", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/pw_all_tip.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/new.gif", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/old.gif", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/colon.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/down.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/h.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/search_btn.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/search_input.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/wind/searchA.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		"Url=images/pwicon/top.png", "Referer=http://localhost:81/phpwind/", ENDITEM, 
		LAST);

	lr_output_message(lr_eval_string("{LoginCount}"));
	if(atoi(lr_eval_string("{LoginCount}"))==1){
		lr_output_message("登入成功");
		lr_end_transaction("Login",LR_PASS);
		}
	else{
	
		lr_output_message("登入失敗");
		lr_end_transaction("Login",LR_FAIL);
		}
	//lr_end_transaction("Login", LR_AUTO);


	
	lr_output_message(lr_eval_string("{verifyLogin}"));

	return 0;
}