飞机订票-1注册用户脚本

 

一、要求:

1、可以注册1000个用户

2、要保证脚本可以持续的运行,不能说运行一次,就不能再运行

3、做好手动事务判断

二、思路:

注册一次用户,用时间参数做用户名的参数化,然后迭代1000次

三、脚本(看着乱,但粘贴到LR中就好了)

Action() {

   web_url("WebTours",  

          "URL=http://127.0.0.1:1080/WebTours/",  

          "TargetFrame=",  

          "Resource=0",  

          "RecContentType=text/html",   

          "Referer=",

          "Snapshot=t1.inf",

          "Mode=HTML",   LAST);

 /*Thank you, elsa1, for registering and welcome to the Web Tours family. We hope we can meet all your current and future travel needs. If you have any questions, feel free to ask our support staff. Click below when you're ready to plan your dream trip*/    

       lr_start_transaction("flight_url");  

 web_reg_find("Search=All",   

         "SaveCount=sign_count",  

         "Text=First time registering? Please complete the form below.",   LAST);

 web_url("sign up now",   

         "URL=http://127.0.0.1:1080/WebTours/login.pl?username=&password=&getInfo=true",

         "TargetFrame=body",

         "Resource=0",  

         "RecContentType=text/html",   

         "Referer=http://127.0.0.1:1080/WebTours/home.html",   

         "Snapshot=t2.inf",  

        "Mode=HTML",   LAST);

   lr_output_message("############%s#############",lr_eval_string("{sign_count}"));

 web_reg_find("Search=All",  

        "SaveCount=sign_count1",   

        "Text=Thank you",   LAST);

 web_submit_data("login.pl",  

       "Action=http://127.0.0.1:1080/WebTours/login.pl",  

       "Method=POST",   

       "TargetFrame=info",  

       "RecContentType=text/html",   

       "Referer=http://127.0.0.1:1080/WebTours/login.pl?username=&password=&getInfo=true",

       "Snapshot=t3.inf",   

       "Mode=HTML",  

       ITEMDATA,  

      "Name=username",

      "Value=Li{Param1}", ENDITEM,  

      "Name=password", "Value=12345", ENDITEM,   

      "Name=passwordConfirm", "Value=12345", ENDITEM,   

      "Name=firstName", "Value=12345", ENDITEM,

      "Name=lastName", "Value=12345", ENDITEM,   

      "Name=address1", "Value=12345", ENDITEM,  

      "Name=address2", "Value=12345", ENDITEM,   

      "Name=register.x", "Value=24", ENDITEM,    

      "Name=register.y", "Value=9", ENDITEM,   LAST);  

  lr_output_message("%s",lr_eval_string("{Param1}"));

  lr_output_message("############%s#############",lr_eval_string("{sign_count1}"));  

  if(strcmp(lr_eval_string("{sign_count}"),"1")){  

            lr_output_message("******************************");  

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

                     if(strcmp(lr_eval_string("{sign_count1}"),"1")){

                      lr_output_message("%%%%%%%%%%%%%%%%%%%%%%%%%%");     

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

                             lr_output_message("#######################");  

 lr_end_transaction("flight_url",LR_PASS);  }

 }

 return 0;

}

 

posted @ 2016-09-12 23:29  Elsa-软件测试工程师  阅读(537)  评论(0编辑  收藏  举报