LoadRunner:phpwind脚本练习之注册


Action()
{


	lr_save_string("http://localhost","URL");
    //获取token
	web_reg_save_param("token",
		"LB=csrf_token=",
		"RB=;",
		"Ord=1",
		"NotFound=WARNING",
		LAST);


	web_url("index.php", 
		"URL={p_url}/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_think_time(10);

	//注册事物开始

	lr_start_transaction("注册开始");


    //检查点-检查注册
	web_reg_find("SaveCount=countzc",
		"Text=恭喜您注册成为phpwind 9.0会员!",
		LAST);

	web_submit_data("index.php_11", 
		"Action={p_url}/phpwind/index.php?m=u&c=register&a=dorun", 
		"Method=POST", 
		"RecContentType=text/html", 
		"Referer={p_url}/phpwind/index.php?m=u&c=register", 
		"Snapshot=t12.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=username", "Value=hzy{usernameone}{usernametwo}", ENDITEM, 
		"Name=password", "Value=123456", ENDITEM, 
		"Name=repassword", "Value=123456", ENDITEM, 
		"Name=email", "Value={usernameone}{usernametwo}@qq.com", ENDITEM, 
		"Name=csrf_token", "Value={token}", ENDITEM, 
		EXTRARES, 
		"Url=themes/site/default/images/common/style_bg.png", "Referer={p_url}/phpwind/index.php?m=u&c=register&a=guide", ENDITEM, 
		"Url=themes/site/default/images/common/core_icon.png", "Referer={p_url}/phpwind/index.php?m=u&c=register&a=guide", ENDITEM, 
		"Url=themes/site/default/images/common/header_dorp.png", "Referer={p_url}/phpwind/index.php?m=u&c=register&a=guide", ENDITEM, 
		"Url=themes/site/default/images/common/loading.gif", "Referer={p_url}/phpwind/index.php?m=u&c=register&a=guide", ENDITEM, 
		LAST);


	web_submit_data("index.php_12", 
		"Action={p_url}/phpwind/index.php?m=u&a=showcredit", 
		"Method=POST", 
		"RecContentType=text/html", 
		"Referer={p_url}/phpwind/index.php?m=u&c=register&a=guide", 
		"Snapshot=t13.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=csrf_token", "Value={token}", ENDITEM, 
		LAST);
	
	//判断注册是否成功
	if(atoi(lr_eval_string("{countzc}"))>0){
		lr_end_transaction("注册开始",LR_PASS);

	}else{
		lr_end_transaction("注册开始",LR_FAIL);
	}

	return 0;
}

猜你喜欢

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