LoadRunner:phpwind脚本练习之登录

//登陆脚本
Action()
{


	  //获取token
	web_reg_save_param("token",
		"LB=csrf_token=",
		"RB=;",
		"Ord=1",
		"NotFound=WARNING",
		LAST);

	web_url("index.php", 
		"URL=http://localhost/phpwind/index.php", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t1.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=themes/site/default/images/main_bg.png", ENDITEM, 
		"Url=themes/site/default/images/common/core_bg.png", ENDITEM, 
		"Url=themes/site/default/images/common/style_icon.png", ENDITEM, 
		"Url=themes/site/default/images/forum/bg.png", ENDITEM, 
		"Url=res/images/face/face_small.jpg", ENDITEM, 
		"Url=res/js/dev/pages/common/global.js?v=20130227", ENDITEM, 
		"Url=res/js/dev/jquery.js?v=20130227", ENDITEM, 
		"Url=res/js/dev/util_libs/ajaxForm.js?v=20130227", ENDITEM, 
		LAST);


	lr_start_transaction("login");

	lr_think_time(21);

    //关联status
	web_reg_save_param("status",
		"LB=statu=",
		"RB=\"",
		"Ord=1",
		"NotFound=WARNING",
		LAST);


	web_submit_data("index.php_3", 
		"Action=http://localhost/phpwind/index.php?m=u&c=login&a=dologin", 
		"Method=POST", 
		"RecContentType=text/html", 
		"Referer=http://localhost/phpwind/index.php", 
		"Snapshot=t2.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=username", "Value={username}", ENDITEM, 
		"Name=password", "Value={passwd}", ENDITEM, 
		"Name=csrf_token", "Value={token}", ENDITEM, 
		"Name=csrf_token", "Value={token}", ENDITEM, 
		LAST);
	lr_output_message("用户信息:%s",lr_eval_string("{username}"));

    //检查点--登录
	web_reg_find("SaveCount=findlogin",
		"Text=每日打卡",
		LAST);


	web_url("index.php_4", 
		"URL=http://localhost/phpwind/index.php?m=u&c=login&a=welcome&_statu={status}", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t3.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=themes/site/default/images/common/core_icon.png", ENDITEM, 
		"Url=themes/site/default/images/common/loading.gif", ENDITEM, 
		"Url=themes/site/default/images/common/header_dorp.png", ENDITEM, 
		"Url=res/js/dev/util_libs/lazySlide.js?v=20130227", ENDITEM, 
		"Url=res/images/face/face_middle.jpg", ENDITEM, 
		"Url=themes/site/default/images/common/style_bg.png", ENDITEM, 
		"Url=res/js/dev/pages/common/sidebarMain.js?v=20130227", ENDITEM, 
		"Url=res/js/dev/pages/bbs/threadManage.js?v=20130227", ENDITEM, 
		"Url=res/js/dev/ui_libs/dialog/dialog.js?v=20130227", ENDITEM, 
		LAST);


	//判断登录是否成功
	if(atoi(lr_eval_string("{findlogin}"))>0){
		lr_end_transaction("login",LR_PASS);

	}else{
		lr_end_transaction("login",LR_FAIL);
	}


	


	return 0;
}


猜你喜欢

转载自blog.csdn.net/qq_24644517/article/details/81436526