飞机票(一个神奇的脚本)

Action()
{
    int i=0;//循环订票的游标变量
    char temp[255];//临时存储字符串变量
    int count=0;//存储循环关联数组长度变量
    char tempfly[255];//临时存储字符串变量

    web_url("WebTours",
        "URL=http://127.0.0.1:1080/WebTours/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_start(NULL);

    web_url("header.html",
        "URL=http://127.0.0.1:1080/WebTours/header.html",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/",
        "Snapshot=t2.inf",
        "Mode=HTTP",
        LAST);

    web_url("welcome.pl",
        "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/",
        "Snapshot=t4.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_end(NULL);

    web_concurrent_start(NULL);

    web_url("hp_logo.png",
        "URL=http://127.0.0.1:1080/WebTours/images/hp_logo.png",
        "Resource=1",
        "RecContentType=image/png",
        "Referer=http://127.0.0.1:1080/WebTours/header.html",
        "Snapshot=t3.inf",
        LAST);

    web_url("webtours.png",
        "URL=http://127.0.0.1:1080/WebTours/images/webtours.png",
        "Resource=1",
        "RecContentType=image/png",
        "Referer=http://127.0.0.1:1080/WebTours/header.html",
        "Snapshot=t5.inf",
        LAST);

    web_concurrent_end(NULL);

    web_concurrent_start(NULL);

    web_url("home.html",
        "URL=http://127.0.0.1:1080/WebTours/home.html",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true",
        "Snapshot=t6.inf",
        "Mode=HTTP",
        LAST);
    web_reg_save_param("sessionuser","LB=<input type=hidden name=userSession value=","RB=>",LAST);//获取用于session值的关联函数
    web_url("nav.pl",
        "URL=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true",
        "Snapshot=t7.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_end(NULL);

    web_concurrent_start(NULL);

    web_url("JSFormSubmit.js",
        "URL=http://127.0.0.1:1080/WebTours/JSFormSubmit.js",
        "Resource=1",
        "RecContentType=application/x-javascript",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
        "Snapshot=t8.inf",
        LAST);

    web_url("mer_login.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/mer_login.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
        "Snapshot=t9.inf",
        LAST);

    web_concurrent_end(NULL);

    lr_start_transaction("login-0");

    lr_think_time(9);
    lr_error_message("sessionuser:%s",lr_eval_string("{sessionuser}"));//打印关联到的用户session值
    web_submit_data("login.pl",
        "Action=http://127.0.0.1:1080/WebTours/login.pl",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
        "Snapshot=t10.inf",
        "Mode=HTTP",
        ITEMDATA,
        "Name=userSession", "Value={sessionuser}", ENDITEM,
        "Name=username", "Value=test001", ENDITEM,
        "Name=password", "Value=123456", ENDITEM,
        "Name=JSFormSubmit", "Value=on", ENDITEM,
        "Name=login.x", "Value=64", ENDITEM,
        "Name=login.y", "Value=15", ENDITEM,
        LAST);

    web_concurrent_start(NULL);

    web_url("nav.pl_2",
        "URL=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/login.pl",
        "Snapshot=t11.inf",
        "Mode=HTTP",
        LAST);

    web_url("login.pl_2",
        "URL=http://127.0.0.1:1080/WebTours/login.pl?intro=true",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/login.pl",
        "Snapshot=t16.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_end(NULL);

    web_concurrent_start(NULL);

    web_url("flights.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/flights.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
        "Snapshot=t12.inf",
        LAST);

    web_url("signoff.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/signoff.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
        "Snapshot=t13.inf",
        LAST);

    web_url("itinerary.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/itinerary.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
        "Snapshot=t14.inf",
        LAST);

    web_url("in_home.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/in_home.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
        "Snapshot=t15.inf",
        LAST);

    web_concurrent_end(NULL);

    lr_end_transaction("login-0",LR_AUTO);

    lr_start_transaction("book-1");

    lr_think_time(11);

    web_url("Search Flights Button",
        "URL=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
        "Snapshot=t17.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_start(NULL);

    web_url("reservations.pl",
        "URL=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",
        "Snapshot=t18.inf",
        "Mode=HTTP",
        LAST);

    web_url("nav.pl_3",
        "URL=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",
        "Snapshot=t19.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_end(NULL);

    web_concurrent_start(NULL);

    web_url("home.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/home.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
        "Snapshot=t20.inf",
        LAST);

    web_url("itinerary.gif_2",
        "URL=http://127.0.0.1:1080/WebTours/images/itinerary.gif",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
        "Mode=HTTP",
        LAST);

    web_url("signoff.gif_2",
        "URL=http://127.0.0.1:1080/WebTours/images/signoff.gif",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
        "Mode=HTTP",
        LAST);

    web_url("in_flights.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/in_flights.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
        "Snapshot=t21.inf",
        LAST);

    web_concurrent_end(NULL);

    web_url("button_next.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/button_next.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",
        "Snapshot=t22.inf",
        LAST);
    web_reg_save_param("flytype","LB=<input type = radio name=outboundFlight value=","RB=>","ORD=ALL","Savelen=18",LAST);//关联取得出现的4张电子机票
//      web_reg_save_param("seatPref","LB=<input type=\"radio\" name=\"seatPref\" value=\"","RB=\" ","ORD=ALL","SaveLen=6",LAST);
//  web_reg_save_param("seatType","LB=<input type=\"radio\" name=\"seatType\" value=\"","RB=\" ","ORD=ALL","SaveLen=8",LAST);
//  lr_error_message("seatPref_1:",lr_eval_string("{seatPref_1}"));
//  lr_error_message("seatPref_2:",lr_eval_string("{seatPref_2}"));
//  lr_error_message("seatPref_3:",lr_eval_string("{seatPref_3}"));
//  lr_error_message("seatType_1:",lr_eval_string("{seatType_1}"));
//  lr_error_message("seatType_2:",lr_eval_string("{seatType_2}"));
//  lr_error_message("seatType_3:",lr_eval_string("{seatType_3}"));
    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=t23.inf",
        "Mode=HTTP",
        ITEMDATA,
        "Name=advanceDiscount", "Value=0", ENDITEM,
        "Name=depart", "Value=Denver", ENDITEM,
        "Name=departDate", "Value=05/29/2013", ENDITEM,
        "Name=arrive", "Value={endplace}", ENDITEM,
        "Name=returnDate", "Value=05/30/2013", ENDITEM,
        "Name=numPassengers", "Value=1", ENDITEM,
        "Name=seatPref", "Value={seatPerf}", ENDITEM,
        "Name=seatType", "Value={seatType}", ENDITEM,
        "Name=.cgifields", "Value=roundtrip", ENDITEM,
        "Name=.cgifields", "Value=seatType", ENDITEM,
        "Name=.cgifields", "Value=seatPref", ENDITEM,
        "Name=findFlights.x", "Value=80", ENDITEM,
        "Name=findFlights.y", "Value=15", ENDITEM,
        LAST);
    lr_error_message("seatPerf:%s",lr_eval_string("{seatPerf}"));
    lr_error_message("seatType:%s",lr_eval_string("{seatType}"));
    count = atoi(lr_eval_string("{flytype_count}"));
    lr_error_message("lenflytype:%d",count);
    lr_error_message("Flytype_1:%s",lr_eval_string("{flytype_1}"));
    lr_error_message("Flytype_2:%s",lr_eval_string("{flytype_2}"));
    lr_error_message("Flytype_3:%s",lr_eval_string("{flytype_3}"));
    lr_error_message("Flytype_4:%s",lr_eval_string("{flytype_4}"));
    for(i=0;i<count;i++)
    {
        sprintf(temp,"{flytype_%d}",i+1);//格式化flytype数组参数格式,取数组中一个存入temp变量
        //lr_save_string(temp,"flytypenum");
        lr_error_message("temp:%s",temp);//打印temp变量的内容
        sprintf(tempfly,"%s",lr_eval_string(temp));//将temp变量通过lr_eval_string函数将temp变量存储的对应loadrunner参数的对应内容存入tempfly变量中
        lr_error_message("tempfly:%s",tempfly);//打印tempfly变量的内容
        lr_error_message("lr_eval_string(tempfly):%s",lr_eval_string(tempfly));//通过lr_eval_string函数取得tempfly变量的内容
        lr_save_string(tempfly,"flytypenum");//将tempfly变量内容存到flytypenum参数中,方便以后lr函数使用
        lr_error_message("flytypenum:%s",lr_eval_string("{flytypenum}"));//打印flytypenum内容
        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=t24.inf",
            "Mode=HTTP",
            ITEMDATA,
            "Name=outboundFlight", "Value={flytypenum}", ENDITEM,
            "Name=numPassengers", "Value=1", ENDITEM,
            "Name=advanceDiscount", "Value=0", ENDITEM,
            "Name=seatType", "Value=Coach", ENDITEM,
            "Name=seatPref", "Value=None", ENDITEM,
            "Name=reserveFlights.x", "Value=63", ENDITEM,
            "Name=reserveFlights.y", "Value=17", ENDITEM,
            LAST);

        web_submit_data("reservations.pl_4",
            "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=t25.inf",
            "Mode=HTTP",
            ITEMDATA,
            "Name=firstName", "Value=test001", ENDITEM,
            "Name=lastName", "Value=test001", ENDITEM,
            "Name=address1", "Value=test001", ENDITEM,
            "Name=address2", "Value=123456", ENDITEM,
            "Name=pass1", "Value=test001 test001", ENDITEM,
            "Name=creditCard", "Value=", ENDITEM,
            "Name=expDate", "Value=", ENDITEM,
            "Name=oldCCOption", "Value=", ENDITEM,
            "Name=numPassengers", "Value=1", ENDITEM,
            "Name=seatType", "Value=Coach", ENDITEM,
            "Name=seatPref", "Value=None", ENDITEM,
            "Name=outboundFlight", "Value={flytypenum}", ENDITEM,
            "Name=advanceDiscount", "Value=0", ENDITEM,
            "Name=returnFlight", "Value=", ENDITEM,
            "Name=JSFormSubmit", "Value=off", ENDITEM,
            "Name=.cgifields", "Value=saveCC", ENDITEM,
            "Name=buyFlights.x", "Value=61", ENDITEM,
            "Name=buyFlights.y", "Value=8", ENDITEM,
            LAST);

    }

    web_url("bookanother.gif",
        "URL=http://127.0.0.1:1080/WebTours/images/bookanother.gif",
        "Resource=1",
        "RecContentType=image/gif",
        "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",
        "Snapshot=t26.inf",
        LAST);

    lr_end_transaction("book-1",LR_AUTO);

    return 0;
}
时间: 2024-11-03 22:05:53

飞机票(一个神奇的脚本)的相关文章

一个神奇的递推公式--转自2108

志远兄发现了一个神奇的递推公式, 某些递推的题目可以看作, 一个个上三角阵, 而问题的解为(1,1) 至 (n,n) 的路径个数, 废话不多说, 上题上代码 以下转自http://www.cnblogs.com/--ZHIYUAN/p/5971367.html 小兔的棋盘 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9447    A

【sehll学习】linux运维一个简单shell脚本监控系统内存

学习shell脚本入门后,慢慢要尝试编写一些脚本练练手,在这先简单的学习写个系统内存的监控. 1.首先先要确定一下截取一下需要关注的内存使用值,可使用free 命令来操作 free -m 显示 一般在监控内存是我们都是截取 第三行(-/+ buffers/cache)的值.确定后可以使用管道线和grep命令来获取这个的值. free -m | grep - | awk  '{print $4}' 获取到他的值为  858 当中 grep -  就是匹配一下要选取的内容,不太熟悉的可以学习一下gr

Android 上的 制表符(tab) —— 一个神奇的字符 (cocos2dx crash)

今天测试发现了游戏的一个问题,系统邮件,如果发了tab,在android上一打开邮件内容就会crash.而且他们很确定是tab的问题. 凭我多个月的经验(确实没多年...)来看,从来没听说在android上会因为一个tab崩溃,而且如果有这个问题,肯定会有很多人遇到,估计早就吵翻天了,搜索了一下,什么可用信息都没有. 于是写个测试工程测试了一下,分别在mac下和windows下,用文本编辑工具编辑了4个txt文档,utf有bom和无bom,内容是" tab abcd ",发现都能正常显

Android 上的 制表符(tab) —— 一个神奇的字符 (二)

接到上回的说,主要是上回那个问题,我觉得是android的bug,黎叔觉得是cocos2dx的bug,叫我去提交bug.所以我又继续研究了下. 上回说到会调用java层的函数去创建一个image,然后作为纹理设置给精灵,在那个地方crash了,此处代码如下: public static void createTextBitmapShadowStroke(String pString, final String pFontName, final int pFontSize, final float

第一个Python爬虫脚本

今天看了一下买来的C#项目书,感觉有点不可理喻,简直就是作者用来圈钱的,视频敷衍了事,源代码莫名其妙...唉...不过今天还是学了新东西,是一个Python爬虫脚本,虽说也是云里雾里,但是也算一个小进步,千里之行始于足下么,下面就把代码给贴出来. import urllib.requestimport urllib.parseimport json content = input('please input what you want to translate : ') url = 'http:

用Python写一个ftp下载脚本

用Python写一个ftp下载脚本 ----基于Red Hat Enterprise Linux Server release 6.4 (Santiago):python 2.6.6 Ps:少侠我接触Python半个月以来接到的第一个需求,虽然如此简单的一个脚本,少侠我磕磕绊绊却用了将近一天半的时间才写出来,但还是很开心,毕竟也粗来了,废话不多说,切入正题.因为一开始没有用过ftplib模块,所以各种谷歌度娘一堆资料杂乱不堪,话不清,理不乱的,本文实现的功能简单,下面介绍一下,以免误导读者. 需

Android以root起一个process[shell脚本的方法]

有时候我们写的app要用uid=0的方式启动一个process,framework层和app层是做不到的,只有通过写脚本,利用am来实现.下面是具体步骤: 1.创建一个包含Main()方法Java project 1.1.创建一个Java project 1.2.添加Main()方法 1.3.导出为jar包 1.4.将java 版本的jar变成android 版本的jar 首先,找到dx工具所在文件夹,如android-sdk/build-tools/20.0.0,并将该文件夹加入到环境变量PA

[Python] 用python做一个游戏辅助脚本,完整思路

一.说明 简述:本文将以4399小游戏<宠物连连看经典版2>作为测试案例,通过识别小图标,模拟鼠标点击,快速完成配对.对于有兴趣学习游戏脚本的同学有一定的帮助. 运行环境:Win10/Python3.5. 主要模块:win32gui(识别窗口.窗口置顶等操作).PIL(屏幕截图).numpy(创建矩阵).operator(比较值).pymouse(模拟鼠标点击). 注意点: 1.如果安装pymouse不成功或者运行报错,可以考虑先通过whl 安装pyHook.然后再通过pip安装pyuseri

MacOS终端下执行一个简单Java脚本

MacOS下安装完Java JVM,配置好环境变量后可以在终端执行一个简单的java脚本程序,其中先使用javac编译器将.java文件编译成字节码文件,然后通过java解释器执行字节码文件. 编写一个简单的脚本 1 class Demo{ 2 3 public static void main(String[] args){ 4 System.out.println("hello world!"); 5 } 6 7 } 编写完后保存为.java格式,这里使用终端查看: 打开终端编译