• WebTours测试脚本分享(半成品练习)


    >>>>>

    1. 启动Web Tours服务。。双击启动。
    2. 输入网址:http://127.0.0.1:1080/WebTours/
    功能解说:
    1. Search Flights Button 订票。
    2. Itinerary Button 形成和查询历史信息。
    3. Home Button 首页。
    4. SignOff Button 退出。

    脚本源码:

    vuser_init脚本:

    vuser_init()
    {
            web_reg_save_param("session",
                           "LB=name="userSession" value="",
                           "RB="/>",
                           LAST);
        web_url("WebTours", 
            "URL=http://localhost:1080/WebTours/", 
            "TargetFrame=", 
            "Resource=0", 
            "RecContentType=text/html", 
            "Referer=", 
            "Snapshot=t77.inf", 
            "Mode=HTML", 
            LAST);
    
        lr_think_time(18);
    
        lr_start_transaction("1_denglu");
    
        web_submit_data("login.pl", 
            "Action=http://localhost:1080/cgi-bin/login.pl", 
            "Method=POST", 
            "TargetFrame=", 
            "RecContentType=text/html", 
            "Referer=http://localhost:1080/cgi-bin/nav.pl?in=home", 
            "Snapshot=t78.inf", 
            "Mode=HTML", 
            ITEMDATA, 
            "Name=userSession", "Value={session}", ENDITEM, 
            "Name=username", "Value=xhx", ENDITEM, 
            "Name=password", "Value=123", ENDITEM, 
            "Name=JSFormSubmit", "Value=on", ENDITEM, 
            "Name=login.x", "Value=72", ENDITEM, 
            "Name=login.y", "Value=15", ENDITEM, 
            LAST);
    
        lr_end_transaction("1_denglu",LR_AUTO);
        lr_output_message("这里是init");
        
        return 0;
    }

    action脚本:

    Action()
    {
    
    
        lr_think_time(14);
    
        lr_start_transaction("2_maipiao");
    
        web_url("Search Flights Button", 
            "URL=http://localhost:1080/cgi-bin/welcome.pl?page=search", 
            "TargetFrame=body", 
            "Resource=0", 
            "RecContentType=text/html", 
            "Referer=http://localhost:1080/cgi-bin/nav.pl?page=menu&in=home", 
            "Snapshot=t79.inf", 
            "Mode=HTML", 
            LAST);
    
        lr_think_time(7);
    //name="outboundFlight" value="010;723;07/16/2017"
        web_reg_save_param("outboundFlight",
                           "LB=name="outboundFlight" value="",
                           "RB=">",
                           "Ord=3",
                           LAST);
        web_submit_data("reservations.pl", 
            "Action=http://localhost:1080/cgi-bin/reservations.pl", 
            "Method=POST", 
            "TargetFrame=", 
            "RecContentType=text/html", 
            "Referer=http://localhost:1080/cgi-bin/reservations.pl?page=welcome", 
            "Snapshot=t80.inf", 
            "Mode=HTML", 
            ITEMDATA, 
            "Name=advanceDiscount", "Value=0", ENDITEM, 
            "Name=depart", "Value={departCity}", ENDITEM, 
            "Name=departDate", "Value=07/16/2017", ENDITEM, 
            "Name=arrive", "Value={arriveCity}", ENDITEM, 
            "Name=returnDate", "Value=07/17/2017", ENDITEM, 
            "Name=numPassengers", "Value=1", ENDITEM, 
            "Name=seatPref", "Value=Window", ENDITEM, 
            "Name=seatType", "Value=First", ENDITEM, 
            "Name=.cgifields", "Value=roundtrip", ENDITEM, 
            "Name=.cgifields", "Value=seatType", ENDITEM, 
            "Name=.cgifields", "Value=seatPref", ENDITEM, 
            "Name=findFlights.x", "Value=68", ENDITEM, 
            "Name=findFlights.y", "Value=3", ENDITEM, 
            LAST);
    
        web_submit_data("reservations.pl_2", 
            "Action=http://localhost:1080/cgi-bin/reservations.pl", 
            "Method=POST", 
            "TargetFrame=", 
            "RecContentType=text/html", 
            "Referer=http://localhost:1080/cgi-bin/reservations.pl", 
            "Snapshot=t81.inf", 
            "Mode=HTML", 
            ITEMDATA, 
            "Name=outboundFlight", "Value={outboundFlight}", ENDITEM, 
            "Name=numPassengers", "Value=1", ENDITEM, 
            "Name=advanceDiscount", "Value=0", ENDITEM, 
            "Name=seatType", "Value=First", ENDITEM, 
            "Name=seatPref", "Value=Window", ENDITEM, 
            "Name=reserveFlights.x", "Value=18", ENDITEM, 
            "Name=reserveFlights.y", "Value=12", ENDITEM, 
            LAST);
            
            
        //<small><B>Thank you for booking through Web Tours.</B></small>
            web_reg_save_param("msg",
                           "LB=<small><B>",
                           "RB=</B></small>",
                           LAST);
        
        web_submit_data("reservations.pl_3", 
            "Action=http://localhost:1080/cgi-bin/reservations.pl", 
            "Method=POST", 
            "TargetFrame=", 
            "RecContentType=text/html", 
            "Referer=http://localhost:1080/cgi-bin/reservations.pl", 
            "Snapshot=t82.inf", 
            "Mode=HTML", 
            ITEMDATA, 
            "Name=firstName", "Value=xxxxxxxxxxx", ENDITEM, 
            "Name=lastName", "Value=xx", ENDITEM, 
            "Name=address1", "Value=", ENDITEM, 
            "Name=address2", "Value=", ENDITEM, 
            "Name=pass1", "Value= ", ENDITEM, 
            "Name=creditCard", "Value=", ENDITEM, 
            "Name=expDate", "Value=", ENDITEM, 
            "Name=oldCCOption", "Value=", ENDITEM, 
            "Name=numPassengers", "Value=1", ENDITEM, 
            "Name=seatType", "Value=First", ENDITEM, 
            "Name=seatPref", "Value=Window", ENDITEM, 
            "Name=outboundFlight", "Value={outboundFlight}", ENDITEM, 
            "Name=advanceDiscount", "Value=0", ENDITEM, 
            "Name=returnFlight", "Value=", ENDITEM, 
            "Name=JSFormSubmit", "Value=off", ENDITEM, 
            "Name=.cgifields", "Value=saveCC", ENDITEM, 
            "Name=buyFlights.x", "Value=59", ENDITEM, 
            "Name=buyFlights.y", "Value=9", ENDITEM, 
            LAST);
        
        if(strstr(lr_eval_string("{msg}"),"Thank you for booking through Web Tours")!=NULL)
        {
            lr_end_transaction("2_maipiao",LR_PASS);
            lr_output_message("订票成功,departCity:%s,arriveCity:%s",
                              lr_eval_string("{departCity}"),
                              lr_eval_string("{arriveCity}"));
        }
        else
        {
            lr_end_transaction("2_maipiao",LR_FAIL);
            lr_output_message("订票失败!");
        }
          //lr_end_transaction("2_maipiao",LR_AUTO);
        //AUTO:自动结尾,不判断正确和错误
        //PASS:以成功状态结束
        //FAIL:以失败状态结束
    
    
    
        return 0;
    }

    vuser_end脚本:

    vuser_end()
    {
            lr_think_time(17);
    
        lr_start_transaction("3_tuichu");
    
        web_url("SignOff Button", 
            "URL=http://localhost:1080/cgi-bin/welcome.pl?signOff=1", 
            "TargetFrame=body", 
            "Resource=0", 
            "RecContentType=text/html", 
            "Referer=http://localhost:1080/cgi-bin/nav.pl?page=menu&in=flights", 
            "Snapshot=t83.inf", 
            "Mode=HTML", 
            LAST);
    
        lr_end_transaction("3_tuichu",LR_AUTO);
        lr_output_message("这里是end");
        return 0;
    }

    >>>>>

  • 相关阅读:
    初试django
    初试mysql
    ASP.NET MVC 做的网站项目
    Update 更新语句使用两个表关联
    SQL Server 输出所有表结构
    循环数据集字段赋默认值
    FireBird.conf配置文件常用参数
    Delphi 获取临时数据集 ClientDataSet
    DELPHI 读取csv 格式文本文件
    获取 临时数据集 的两种方法
  • 原文地址:https://www.cnblogs.com/xuehx/p/7346196.html
Copyright © 2020-2023  润新知