飞机订票-2登录成功脚本

 

一、说明

1、登录脚本放在init中;

2、对session做了关联,保证登录成功;

3、对用户名做了文件参数化,保证每次迭代的用户名不同,持续化,密码统一123456;

其实我是想要和注册脚本一起执行,这样用户名就是在注册的时候被处理为时间参数化

4、使用此脚本前,注意要对用户名提前注册,并将注册好的用户名直接写在文件参数化的表格中;

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

vuser_init() {  

  web_reg_save_param("session",  

          "LB=<input type=hidden name=userSession value=",

          "RB=>",  

          "Ord=1",   LAST);  

  web_reg_find("Search=All",   

         "SaveCount=count",   

         "Text=Welcome",   LAST);

 web_url("WebTours",  

        "URL=http://127.0.0.1:1080/WebTours/",   LAST);

 web_submit_data("login.pl",   

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

        "Method=POST",   

        "TargetFrame=body",  

        "RecContentType=text/html",

        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",  

        "Snapshot=t2.inf",   

        "Mode=HTML",   

        ITEMDATA,   

        "Name=userSession", "Value={session}", ENDITEM,  

        "Name=username", "Value=Elsa{username}", ENDITEM,  

        "Name=password", "Value=bean", ENDITEM,   

       "Name=JSFormSubmit", "Value=off", ENDITEM,  

       "Name=login.x", "Value=56", ENDITEM,

       "Name=login.y", "Value=10", ENDITEM,   LAST);

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

      return 0;

}

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