loadrunner之关联取随机参数

 /*
      得到响应数据中符合左边界LB,右边界RB所有的值,储存在outboundFlight数组中。
      ORD默认为1,若ORD=1,则outboundFlight为符合条件的第一个数。
      ORD=ALL,,则outboundFlight为符合条件的数组。
    */
    web_reg_save_param("outboundFlight",
        "LB=name=outboundFlight value=",
        "RB=>",
        "ORD=All",               
        LAST);
    
    web_submit_data("reservations.pl_2",
        "Action=http://127.0.0.1:1080/WebTours/reservations.pl",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",
        "Snapshot=t22.inf",
        "Mode=HTTP",
        ITEMDATA,
        "Name=advanceDiscount", "Value=0", ENDITEM,
        "Name=depart", "Value={city}", ENDITEM,
        "Name=departDate", "Value=08/15/2017", ENDITEM,
        "Name=arrive", "Value={gocity}", ENDITEM,
        "Name=returnDate", "Value=08/16/2017", ENDITEM,
        "Name=numPassengers", "Value=1", ENDITEM,
        "Name=seatPref", "Value=Window", ENDITEM,
        "Name=seatType", "Value=Coach", ENDITEM,
        "Name=.cgifields", "Value=roundtrip", ENDITEM,
        "Name=.cgifields", "Value=seatType", ENDITEM,
        "Name=.cgifields", "Value=seatPref", ENDITEM,
        "Name=findFlights.x", "Value=78", ENDITEM,
        "Name=findFlights.y", "Value=10", ENDITEM,
        LAST);

    web_reg_find("Text=Flight Reservation",
        LAST);
    //初始化随机数,随机选取种子
    srand(time(NULL));
    //在数组(outboundFlight)中取一个随机数,赋值到另一个变量(outboundFlight_num)。
    lr_save_string(lr_paramarr_random("outboundFlight"), "outboundFlight_num");
    web_submit_data("reservations.pl_3",
        "Action=http://127.0.0.1:1080/WebTours/reservations.pl",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",
        "Snapshot=t23.inf",
        "Mode=HTTP",
        ITEMDATA,
        "Name=outboundFlight", "Value={outboundFlight_num}", ENDITEM,
        "Name=numPassengers", "Value=1", ENDITEM,
        "Name=advanceDiscount", "Value=0", ENDITEM,
        "Name=seatType", "Value=Coach", ENDITEM,
        "Name=seatPref", "Value=Window", ENDITEM,
        "Name=reserveFlights.x", "Value=51", ENDITEM,
        "Name=reserveFlights.y", "Value=10", ENDITEM,
        LAST);

源自:https://blog.csdn.net/julielele/article/details/77368480?utm_source=copy 

posted on 2018-09-29 08:59  zz测试笔记  阅读(823)  评论(0编辑  收藏  举报