`
javantsky
  • 浏览: 83660 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

loadrunner测试脚本

 
阅读更多

自己弄的一个脚本,记录下,供以后参考。

 

Action()
{

    web_add_cookie("citycode=310000; DOMAIN=testya.gewala.net");

    web_url("login.xhtml",
        "URL=http://testya.gewala.net/login.xhtml?TARGETURL=/cinema/searchOpi.xhtml",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTTP",
        LAST);

    web_url("loadSubjectHead.xhtml",
        "URL=http://testya.gewala.net/ajax/common/loadSubjectHead.xhtml?tagNo=1359523577500814558&head=header",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/login.xhtml?TARGETURL=/cinema/searchOpi.xhtml",
        "Snapshot=t17.inf",
        "Mode=HTTP",
        LAST);

    web_url("getCaptchaId.xhtml",
        "URL=http://testya.gewala.net/getCaptchaId.xhtml?r=1359523585968",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/login.xhtml?TARGETURL=/cinema/searchOpi.xhtml",
        "Snapshot=t19.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_start(NULL);

    web_url("captcha.xhtml",
        "URL=http://testya.gewala.net/captcha.xhtml?captchaId=CiQwFXdgQBHuJLt7cb708617&r=1359523586046",
        "Resource=1",
        "RecContentType=image/jpeg",
        "Referer=http://testya.gewala.net/login.xhtml?TARGETURL=/cinema/searchOpi.xhtml",
        "Snapshot=t21.inf",
        LAST);

    web_concurrent_end(NULL);

//获取电影id
    web_reg_save_param("test_movieIds",
        "LB=id=\"",
        "RB=\" rel=\"smovieid",
        "ORD=ALL",
        "NotFound=WARNING",
        "Search=Body",
        LAST);

    web_submit_data("check_user.xhtml",
        "Action=http://testya.gewala.net/cas/check_user.xhtml",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/login.xhtml?TARGETURL=/cinema/searchOpi.xhtml",
        "Snapshot=t22.inf",
        "Mode=HTTP",
        ITEMDATA,
        "Name=TARGETURL", "Value=/cinema/searchOpi.xhtml", ENDITEM,
        "Name=j_username", "Value={username}", ENDITEM,
        "Name=j_password", "Value={passwd}", ENDITEM,
        "Name=captchaId", "Value=CiQwFXdgQBHuJLt7cb708617", ENDITEM,
        "Name=captcha", "Value=drkj", ENDITEM,
        LAST);

    if(atoi(lr_eval_string("{test_movieIds_count}")) == 0){
        return 0;
    }

    lr_save_string(lr_eval_string(lr_paramarr_random("test_movieIds")),"testmovieId");
    lr_log_message("testmovieId is %s",lr_eval_string("{testmovieId}"));

    //lr_think_time(3);

    //获取mpid
    web_reg_save_param("test_mpIds",
        "LB=href=\"/cinema/order/step1.shtml?mpid=",
        "RB=\" class=\"button minBt  redBt",
        "ORD=ALL",
        "NotFound=ERROR",
        "Search=Body",
        LAST);
    web_url("searchOpi.xhtml_2",
        "URL=http://testya.gewala.net/cinema/searchOpi.xhtml?movieid={testmovieId}&cinemaid=&fyrq=&spkey=&edition=&language=&cinemaname=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t47.inf",
        "Mode=HTTP",
        LAST);

    lr_save_string(lr_eval_string(lr_paramarr_random("test_mpIds")),"testmpid");
    lr_log_message("testmpid is %s",lr_eval_string("{testmpid}"));

    web_url("loadSubjectHead.xhtml_4",
        "URL=http://testya.gewala.net/ajax/common/loadSubjectHead.xhtml?tagNo=1359523611578634561&head=header",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/cinema/searchOpi.xhtml?movieid={testmovieId}&cinemaid=&fyrq=&spkey=&edition=&language=&cinemaname=",
        "Snapshot=t48.inf",
        "Mode=HTTP",
        LAST);

    web_url("getCountyBooking.xhtml_3",
        "URL=http://testya.gewala.net/movie/ajax/getCountyBooking.xhtml?movieid={testmovieId}",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/cinema/searchOpi.xhtml?movieid={testmovieId}&cinemaid=&fyrq=&spkey=&edition=&language=&cinemaname=",
        "Snapshot=t49.inf",
        "Mode=HTTP",
        LAST);

    web_url("getIndexOtherRandomAd.xhtml_3",
        "URL=http://testya.gewala.net/ajax/common/getIndexOtherRandomAd.xhtml?pid=ticketorder&tag=movie&relatedid={testmovieId}",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/cinema/searchOpi.xhtml?movieid={testmovieId}&cinemaid=&fyrq=&spkey=&edition=&language=&cinemaname=",
        "Mode=HTTP",
        LAST);


    lr_start_transaction("order_begin");


    //判断场次是否有效
    web_reg_save_param("test_mpok",
        "LB=<div class=\"backMsg\"",
        "RB=/div>",
        "NotFound=WARNING",
        "Search=Body",
        LAST);
    web_url("step1.shtml",
        "URL=http://testya.gewala.net/cinema/order/step1.shtml?mpid={testmpid}",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://testya.gewala.net/cinema/searchOpi.xhtml?movieid={testmovieId}&cinemaid=&fyrq=&spkey=&edition=&language=&cinemaname=",
        "Snapshot=t50.inf",
        "Mode=HTTP",
        LAST);

    lr_log_message("testmpok is %s",lr_eval_string("{test_mpok}"));

    if (strcmp(lr_eval_string ("{test_mpok}"), ">场次不存在!<") != 0){

        web_concurrent_start(NULL);
   
        web_url("captcha.xhtml_2",
            "URL=http://testya.gewala.net/captcha.xhtml?captchaId=mx3QsWqgUxJYJpbV8d9e4089&r=0.6162794590989227",
            "Resource=1",
            "RecContentType=image/jpeg",
            "Referer=http://testya.gewala.net/cinema/order/step1.shtml?mpid={testmpid}",
            "Snapshot=t56.inf",
            LAST);
   
        web_concurrent_end(NULL);
   
   
        web_url("loadSubjectHead.xhtml_5",
            "URL=http://testya.gewala.net/ajax/common/loadSubjectHead.xhtml?tagNo=1359523617171583441&head=header",
            "Resource=0",
            "RecContentType=text/html",
            "Referer=http://testya.gewala.net/cinema/order/step1.shtml?mpid={testmpid}",
            "Snapshot=t59.inf",
            "Mode=HTTP",
            LAST);
   

        web_url("getIndexOtherRandomAd.xhtml_4",
            "URL=http://testya.gewala.net/ajax/common/getIndexOtherRandomAd.xhtml?pid=ticketorder&tag=movie&relatedid={testmovieId}",
            "Resource=0",
            "RecContentType=text/html",
            "Referer=http://testya.gewala.net/cinema/order/step1.shtml?mpid={testmpid}",
            "Mode=HTTP",
            LAST);
        //获取座位号
        web_reg_save_param("test_ids",
            "LB=<div id=",
            "RB=hasSeat",
            "ORD=ALL",
            "SaveOffset=2",
            "SaveLen=8",
            "NotFound=WARNING",
            "Search=Body",
            LAST);
   
        web_url("getSeatPage.shtml",
            "URL=http://testya.gewala.net/ajax/ticket/getSeatPage.shtml?mpid={testmpid}&r=1359523617484",
            "Resource=0",
            "RecContentType=text/html",
            "Referer=http://testya.gewala.net/cinema/order/step1.shtml?mpid={testmpid}",
            "Snapshot=t63.inf",
            "Mode=HTTP",
            LAST);

        //int count_;
        //count_ = atoi(lr_eval_string("{test_ids_count}"));
        lr_log_message("count is %s",lr_eval_string("{test_ids_count}"));
        if(atoi(lr_eval_string("{test_ids_count}")) > 0){
       
            lr_save_string(lr_eval_string(lr_paramarr_random("test_ids")),"testSeatid");
            lr_log_message("seatid is %s",lr_eval_string("{testSeatid}"));
       
            lr_think_time(4);


            web_reg_save_param("order_id",
                "LB=\"retval\":\"",
                "RB=\",\"success",
                "NotFound=WARNING",
                "Search=Body",
                LAST);
            web_reg_save_param("order_status",
                "LB=success\":",
                "RB=}",
                "NotFound=WARNING",
                "Search=Body",
                LAST);

            web_submit_data("step2.shtml",
                "Action=http://testya.gewala.net/cinema/order/step2.shtml",
                "Method=POST",
                "RecContentType=text/html",
                "Referer=http://testya.gewala.net/cinema/order/step1.shtml?mpid={testmpid}",
                "Snapshot=t64.inf",
                "Mode=HTTP",
                ITEMDATA,
                "Name=goodsid", "Value=", ENDITEM,
                "Name=quantity", "Value=1", ENDITEM,
                "Name=mpid", "Value={testmpid}", ENDITEM,
                "Name=seatid", "Value={testSeatid}", ENDITEM,
                "Name=captchaId", "Value=mx3QsWqgUxJYJpbV8d9e4089", ENDITEM,
                "Name=mobile", "Value=18721512675", ENDITEM,
                "Name=captcha", "Value=aaaa", ENDITEM,
                "Name=buynowBtn", "Value=立即购买", ENDITEM,
                LAST);

            lr_log_message("order_status : %s",lr_eval_string ("{order_status}"));
            lr_log_message("order_id : %s",lr_eval_string ("{order_id}"));
            if (strcmp(lr_eval_string ("{order_status}"), "true") == 0){
                web_url("order.xhtml",
                    "URL=http://testya.gewala.net/gewapay/order.xhtml?orderId={order_id}",
                    "Resource=0",
                    "RecContentType=text/html",
                    "Referer=",
                    "Snapshot=t65.inf",
                    "Mode=HTTP",
                    LAST);
           
       
                web_url("loadSubjectHead.xhtml_6",
                    "URL=http://testya.gewala.net/ajax/common/loadSubjectHead.xhtml?tagNo=1359523642234895568&head=header",
                    "Resource=0",
                    "RecContentType=text/html",
                    "Referer=http://testya.gewala.net/gewapay/order.xhtml?orderId={order_id}",
                    "Snapshot=t72.inf",
                    "Mode=HTTP",
                    LAST);
           
                web_submit_data("saveOrderInfo.xhtml",
                    "Action=http://testya.gewala.net/ajax/trade/saveOrderInfo.xhtml",
                    "Method=POST",
                    "RecContentType=text/html",
                    "Referer=http://testya.gewala.net/gewapay/order.xhtml?orderId={order_id}",
                    "Snapshot=t74.inf",
                    "Mode=HTTP",
                    ITEMDATA,
                    "Name=mobile", "Value=18721512675", ENDITEM,
                    "Name=orderId", "Value={order_id}", ENDITEM,
                    LAST);
           
                web_url("confirmOrder.xhtml",
                    "URL=http://testya.gewala.net/gewapay/confirmOrder.xhtml?orderId={order_id}",
                    "Resource=0",
                    "RecContentType=text/html",
                    "Referer=",
                    "Snapshot=t75.inf",
                    "Mode=HTTP",
                    LAST);
           
           
                web_url("loadSubjectHead.xhtml_7",
                    "URL=http://testya.gewala.net/ajax/common/loadSubjectHead.xhtml?tagNo=1359523650609193574&head=header",
                    "Resource=0",
                    "RecContentType=text/html",
                    "Referer=http://testya.gewala.net/gewapay/confirmOrder.xhtml?orderId={order_id}",
                    "Snapshot=t82.inf",
                    "Mode=HTTP",
                    LAST);
            }//if (strcmp(lr_eval_string ("{order_status}"), "true") == 0)

        }//if(atoi(lr_eval_string("{test_ids_count}") > 0)

    }//if (strcmp(lr_eval_string ("{test_mpok}"), ">场次不存在!<") == 0)

   
    lr_end_transaction("order_begin", LR_AUTO);

    web_url("logout.xhtml",
        "URL=http://testya.gewala.net/cas/logout.xhtml?ptn=smp",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t83.inf",
        "Mode=HTTP",
        LAST);

    return 0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics