web类协议脚本-飞机订票系统示例

以下是LR自带的飞机订票系统的Demo,希望能帮助大家。

Action()
{
 int iRand;
 int iTmp;
 char *strTmpA;
 char *strTmpB;
 char *strTmpC;
 char *position;
 if ((strTmpA = (char *)malloc(100 * sizeof(char))) == NULL) {
     lr_output_message ("Insufficient memory available");
     return -1;
    }
 if ((strTmpB = (char *)malloc(100 * sizeof(char))) == NULL) {
     lr_output_message ("Insufficient memory available");
     return -1;
 }
 if ((strTmpC = (char *)malloc(100 * sizeof(char))) == NULL) {
     lr_output_message ("Insufficient memory available");
     return -1;
 }
 web_reg_save_param("userSession",
  "LB=<input type=hidden name=userSession value=",
  "RB=>",
  LAST);
 web_url("WebTours",
  "URL=http://127.0.0.1:1080/WebTours/",
  "TargetFrame=",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Snapshot=t2.inf",
  "Mode=HTML",
  LAST);
 //lr_start_transaction("login");
 //r_think_time(17);
 web_submit_data("login.pl",
  "Action=http://127.0.0.1:1080/WebTours/login.pl",
  "Method=POST",
  "TargetFrame=",
  "RecContentType=text/html",
  "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
  "Snapshot=t3.inf",
  "Mode=HTML",
  ITEMDATA,
  "Name=userSession", "Value={userSession}", ENDITEM,
  "Name=username", "Value=demo", ENDITEM,
  "Name=password", "Value=demo", ENDITEM,
  "Name=JSFormSubmit", "Value=on", ENDITEM,
  "Name=login.x", "Value=26", ENDITEM,
  "Name=login.y", "Value=5", ENDITEM,
  LAST);
 //lr_end_transaction("login",LR_AUTO);
 lr_start_transaction("order");
 //r_think_time(9);
web_reg_save_param("City",
  "LB=<option ",
  "RB=</option>",
  "Ord=ALL",
  LAST);
web_url("Search Flights Button",
  "URL=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",
  "TargetFrame=body",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
  "Snapshot=t4.inf",
  "Mode=HTML",
  LAST);
 web_url("FormDateUpdate.class",
  "URL=http://127.0.0.1:1080/WebTours/FormDateUpdate.class",
  "TargetFrame=",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Mode=HTML",
  LAST);
 web_url("CalSelect.class",
  "URL=http://127.0.0.1:1080/WebTours/CalSelect.class",
  "TargetFrame=",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Mode=HTML",
  LAST);
 web_url("Calendar.class",
  "URL=http://127.0.0.1:1080/WebTours/Calendar.class",
  "TargetFrame=",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Mode=HTML",
  LAST);
 //r_think_time(7);
 lr_output_message(lr_eval_string("The City count is:{City_count}"));
 iTmp = atoi(lr_eval_string("{City_count}")); //城市个数转换成int类型
 //   srand(time(NULL));
 iRand = rand() % (iTmp/2+1);   //随机数+1的含义是避免出现随机数是0得到City_0 加1得到的最终随机数=随机数+1;
 sprintf(strTmpA,"{City_%d}", iRand); //获取随机取到的城市编号
 sprintf(strTmpA, lr_eval_string(strTmpA)); //获取城市编号对应的值
 lr_message("The depart city is %s", strTmpA); //打印城市名称 value="Frankfurt">Frankfurt
    position = (char *)strstr(strTmpA, ">");  //定位到">"位置
 lr_save_string(position+1, "DepartCity");  //">"位置+1就是要获取的城市名称

 iRand = rand() % (iTmp/2+1);
 sprintf(strTmpB,"{City_%d}", iRand);
 sprintf(strTmpB, lr_eval_string(strTmpB));
 lr_message("The depart city is %s", strTmpB);
    position = (char *)strstr(strTmpB, ">");
 lr_save_string(position+1, "ArriveCity");
 while(strcmp(lr_eval_string("{DepartCity}"), lr_eval_string("{ArriveCity}")) == 0)
    {
  iRand = rand() % (iTmp/2) +1;

  sprintf(strTmpB,"{City_%d}", iRand);

  sprintf(strTmpB, lr_eval_string(strTmpB));

  lr_message("The depart city is %s", strTmpB);

  position = (char *)strstr(strTmpB, ">"); 

  lr_save_string(position+1, "ArriveCity");
 }
 web_reg_save_param("FlightNo",
  "LB=<input type = radio name=outboundFlight value=",
  "RB=>",
  "Ord=ALL",
  LAST);
//<input type = radio name=outboundFlight value=010;386;04/19/2015 checked >Blue Sky Air 010<
 web_submit_data("reservations.pl",
  "Action=http://127.0.0.1:1080/WebTours/reservations.pl",
  "Method=POST",
  "TargetFrame=",
  "RecContentType=text/html",
  "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",
  "Snapshot=t5.inf",
  "Mode=HTML",
  ITEMDATA,
  "Name=advanceDiscount", "Value=0", ENDITEM,
  "Name=depart", "Value={DepartCity}", ENDITEM,
  "Name=departDate", "Value={departDate}", ENDITEM,
  "Name=arrive", "Value={ArriveCity}", ENDITEM,
  "Name=returnDate", "Value={arriveDate}", ENDITEM,
  "Name=numPassengers", "Value=1", ENDITEM,
  "Name=seatPref", "Value=None", 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=54", ENDITEM,
  "Name=findFlights.y", "Value=5", ENDITEM,
  LAST);
iTmp = atoi(lr_eval_string("{FlightNo_count}"));
 iRand = rand() % iTmp +1;
 //iRand = 1;
 sprintf(strTmpC,"{FlightNo_%d}", iRand);
 sprintf(strTmpC, lr_eval_string(strTmpC));
 lr_message("The Flight No is %s", strTmpC);
    position = (char *)strstr(strTmpC, "checked");
 if (position != NULL) {
  sprintf(position -1, "\0");
 }
 lr_save_string(strTmpC, "FlightNewNo");
 web_submit_data("reservations.pl_2",
  "Action=http://127.0.0.1:1080/WebTours/reservations.pl",
  "Method=POST",
  "TargetFrame=",
  "RecContentType=text/html",
  "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",
  "Snapshot=t6.inf",
  "Mode=HTML",
  ITEMDATA,
  "Name=outboundFlight", "Value={FlightNewNo}", 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=15", ENDITEM,
  "Name=reserveFlights.y", "Value=2", ENDITEM,
  LAST);
 //r_think_time(4);
 web_submit_data("reservations.pl_3",
  "Action=http://127.0.0.1:1080/WebTours/reservations.pl",
  "Method=POST",
  "TargetFrame=",
  "RecContentType=text/html",
  "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",
  "Snapshot=t7.inf",
  "Mode=HTML",
  ITEMDATA,
  "Name=firstName", "Value=Demo", ENDITEM,
  "Name=lastName", "Value=Demo", ENDITEM,
  "Name=address1", "Value=AAA", ENDITEM,
  "Name=address2", "Value=", ENDITEM,
  "Name=pass1", "Value=Demo Demo", 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={FlightNewNo}", ENDITEM,
  "Name=advanceDiscount", "Value=0", ENDITEM,
  "Name=returnFlight", "Value=", ENDITEM,
  "Name=JSFormSubmit", "Value=off", ENDITEM,
  "Name=.cgifields", "Value=saveCC", ENDITEM,
  "Name=buyFlights.x", "Value=37", ENDITEM,
  "Name=buyFlights.y", "Value=5", ENDITEM,
  LAST);
 lr_end_transaction("order",LR_AUTO);
 //lr_start_transaction("logout");
 ////r_think_time(13);
 web_url("welcome.pl",
  "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1",
  "TargetFrame=",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
  "Snapshot=t8.inf",
  "Mode=HTML",
  LAST);
 //lr_end_transaction("logout",LR_AUTO);
 free(strTmpA);
 free(strTmpB);
 free(strTmpC);
 return 0;
}

原文地址:https://www.cnblogs.com/ssj0723/p/9581713.html

时间: 2024-10-09 07:38:49

web类协议脚本-飞机订票系统示例的相关文章

windows API 开发飞机订票系统 图形化界面 (四)

接下来的是录入航班.修改航班信息功能的实现: 1 //录入航班 2 BOOL EntryFlight(HWND hEntryDlg){ 3 4 TCHAR szDiscount[16]; 5 TCHAR szFare[16],szSeat_Number[16]; 6 TCHAR szFlight_Number[16], szDate[16]; 7 TCHAR szDeparture[16], szDestination[16]; 8 TCHAR szTakeOff_Time[16], szLan

飞机订票系统

飞机订票系统 // 飞机订票系统.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <stdio.h> #include <string.h> #include<stdlib.h> #include<conio.h> #define N 2 typedef struct plane { char ID[10]; char Start_Place[10]; char End_Place

qtp脚本测试飞机订票系统(代码)

嗯,以前没怎么研究过这个,最近做课设用到了,顺便发一下. 有要用的话,自己改一下路径什么的.版本qtp10.0 Mainaction Dim AgentName Dim Password Dim DateOfFlight Dim FaxNumber Dim SelectTest Dim DateOfUpdate Dim DeleteName Dimy Dim e Dim e Datatable.ImportSheet "C:\Users\yue\Desktop\yuetest\excel\Mai

C语言实现-航空订票系统(飞机订票系统)

开发环境:CodeBlocks 开发语言:C 实现功能:登录,订票,退票 数据存储:文本读写 涉及文件: ? 相关文件下载: 码云:https://gitee.com/ikaros-521/c_project/tree/master/%E9%A3%9E%E6%9C%BA%E8%AE%A2%E7%A5%A8%E7%B3%BB%E7%BB%9F%EF%BC%88%E8%88%AA%E7%A9%BA%E8%AE%A2%E7%A5%A8%E7%B3%BB%E7%BB%9F%EF%BC%89 程序主界面:

windows API 开发飞机订票系统 图形化界面 (三)

来吧,接下来是各个功能的函数的实现代码. 首先,程序运行时加载读入账户信息和航班信息.接下来就该读取文件了. 我把账户资料和航班信息储存在了.txt文件里 那么问题就来了,挖掘机...额,不对,应该怎么读入账户资料和航班信息? 每一行是结构体的一个成员,我读入的方式是一行一行读入. 两个读入函数代码如下: 1 //读入账户信息 2 BOOL ReadAccountData(HWND hwndDlg){ 3 4 FILE *fp; 5 6 passenger = (Passenger *)mall

UTF简单脚本录制(飞机订票系统)

1.直接录制脚本-文件-新建-测试-GUI-创建 2.录制配置-添加程序路径 3.录制-输入用户名密码.机票事件地点.查询航班情况.登机人,提交 Dialog("Login").WinEdit("Agent Name:").SetSelection 0,6 Dialog("Login").WinEdit("Agent Name:").Set "dfsdf" Dialog("Login")

【C语言】火车订票系统

#include<stdio.h> #include<string.h> #include<iostream> #include<process.h> #include<conio.h> #include<iomanip> #define max 60 typedef struct customer {//乘客信息 char name[10];//姓名 int  amount;//订票数 char rank;//火车票种类:硬座.软座

C语言课程设计——电影院订票系统

1. 课题简介 大家都爱看电影,现请参考一个熟悉电影票预订系统,实现C语言版的订票系统.了解订票如何实现的.系统主要有2类用户:管理员用户和顾客用户. 管理员用户登录系统后,实现电影放映厅信息管理和电影场次信息管理.具体菜单有: 1.电影放映厅信息管理 选择该菜单能展示所有放映厅,用户输入某个放映厅编号后,能实现对放映厅增加.删除.修改功能.主要对movie_house.txt数据修改. 放映厅主要字段信息有: 放映厅编号.放映厅名称.放映厅行数.放映厅列数.放映厅座位初始状态. 假如放映厅是一

关于铁路订票系统如何改善设计的讨论

由12306.cn谈谈网站性能技术 铁路订票系统的简单设计