zoukankan      html  css  js  c++  java
  • 典型LoadRunner脚本

    Action()
    {
    	int rc = 0;
    	int cmp_result = 0;
        char over_msg[] = ""真遗憾,好心塞,手慢了一下,已经被人抢走了,再去看看别的吧"";
    	char return_msg[100];
    	////恭喜,赶快到网络良好的地方去付款吧!手快有手慢无,30分钟内哦
    
    	web_reg_find("Text="status":"1"",
    		"SaveCount=login_count",
    		LAST);
    
    	web_reg_save_param_ex(
    		"ParamName=login_cookie_1",
    		"LB=Set-Cookie: ",
    		"RB=; Path=",
    		SEARCH_FILTERS,
    		"Scope=Headers",
    		"RequestUrl=*/agentlogin.do*",
    		LAST);
    
    	lr_start_transaction("agentlogin");
    
    	web_submit_data("agentlogin",
    		"Action=http://172.16.10.125:8080/customer-app-web/appC/login/agentlogin.do",
    		"Method=GET",
    		"TargetFrame=",
    		"RecContentType=text/html",
    		"Referer=http://172.16.10.125:8080/customer-app-web/appC/login/agentlogin.do",
    		"Snapshot=t1.inf",
    		"Mode=HTML",
    		ITEMDATA,
    		"Name=phone","Value={phone}", ENDITEM,
            "Name=userPass", "Value={password}", ENDITEM,
             LAST);
            
    	if(atoi(lr_eval_string("{login_count}"))==0)
    	{
    	    lr_end_transaction("agentlogin", LR_FAIL);
    	}
    	else
    	{	
    	    lr_end_transaction("agentlogin", LR_PASS);
    	    lr_output_message("login successfu! cookie value is: %s", lr_eval_string("{login_cookie_1}"));
    
    		web_reg_find("Text="status":"1"",
    		"SaveCount=buy_count",
    		LAST);
    
    		web_reg_save_param_ex(
    			"ParamName=buy_result",
    			"LB="data":",
    			"RB=}",
    			SEARCH_FILTERS,
    			"Scope=Body",
    			"RequestUrl=*/buyImmediately.do*",
    			LAST);
    
    		lr_rendezvous("start_buy");
    
    		lr_start_transaction("buyImmediately");
    
    		web_submit_data("buyImmediately",
    			"Action=http://172.16.10.125:8080/customer-app-web/houses/buyImmediately.do",
    			"Method=GET",
    			"TargetFrame=",
    			"RecContentType=text/html",
    			"Referer=http://172.16.10.125:8080/customer-app-web/houses/buyImmediately.do",
    			"Snapshot=t1.inf",
    			"Mode=HTML",
    			ITEMDATA,
    			"Name=activityId","Value=21", ENDITEM,
    			"Name=Cookie","Value={login_cookie_1}", ENDITEM,
    			LAST);
    
    		if(atoi(lr_eval_string("{buy_count}"))==0)
    		{
    			lr_end_transaction("buyImmediately", LR_FAIL);
    		}
    		else
    		{
    
                rc = lr_convert_string_encoding(lr_eval_string("{buy_result}"), LR_ENC_UTF8, LR_ENC_SYSTEM_LOCALE, "returnstring");
    			if (rc == 0) {
    				//lr_output_message("convert result is: %d", rc);
    
    				//lr_output_message("buy result is: %s", lr_eval_string("{returnstring}"));
    
    				sprintf(return_msg, "%s", lr_eval_string("{returnstring}")); 
    				//lr_output_message("save result is: %s", return_msg);
    
    				cmp_result = strcmp(over_msg, return_msg);
    				if (cmp_result == 0) {
    					lr_end_transaction("buyImmediately", LR_FAIL);
    				}
    				else{
    					lr_end_transaction("buyImmediately", LR_PASS);
    				}
    			}
    			else{
    				lr_end_transaction("buyImmediately", LR_FAIL);
    			}
    			
    
    		}
    
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    数据库连接池
    JDBC事务
    oracle 11g
    python自动化办公1-os模块学习
    python模块学习1
    requests-post请求
    linux学习二-目录文件相关命令
    Linux学习一常见的7个命令及命令的信息查看
    python-文件操作
    异常以及异常处理
  • 原文地址:https://www.cnblogs.com/hushaojun/p/4760568.html
Copyright © 2011-2022 走看看