web类协议脚本-飞机订票系统示例
以下是LR自带的飞机订票系统的Demo,希望能帮助大家。
Action()
{
int iRand;
int iTmp;
char *strTmpA;
char *strTmpB;
char *strTmpC;
char *position;
if ((strTmpA = (char *)malloc( * sizeof(char))) == NULL) {
lr_output_message ("Insufficient memory available");
return -;
}
if ((strTmpB = (char *)malloc( * sizeof(char))) == NULL) {
lr_output_message ("Insufficient memory available");
return -;
}
if ((strTmpC = (char *)malloc( * sizeof(char))) == NULL) {
lr_output_message ("Insufficient memory available");
return -;
}
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/+); //随机数+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+, "DepartCity"); //">"位置+1就是要获取的城市名称 iRand = rand() % (iTmp/+);
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+, "ArriveCity");
while(strcmp(lr_eval_string("{DepartCity}"), lr_eval_string("{ArriveCity}")) == )
{
iRand = rand() % (iTmp/) +; 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+, "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 +;
//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 -, "\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 ;
}
web类协议脚本-飞机订票系统示例的更多相关文章
- 【性能测试】Loadrunner12.55(二)-飞机订票系统-脚本录制
1.1 飞机订票系统 Loadrunner 12.55不会自动安装飞机订票系统,要自己手动安装. 我们需要下载Web Tools以及一个小插件strawberry https://marketplac ...
- loadrunner飞机订票系统从登陆订票退票登出的脚本实现代码调试通过
在LR自带的飞机订票系统中,完整模拟一个用户从登陆->订票->退票->登出这样一个业务流程,分解每个事务为一个Action: 进入首页->登陆->进入订票页面->选 ...
- loadrunner笔记(二):飞机订票系统--客户信息注册
(一) 几个重要概念说明 集合点:同步虚拟用户,以便同一时间执行任务. 事务:事务是指服务器响应用户请求所用的时间,当然它可以衡量某个操作,如登录所需要的时间,也可以衡量一系列的操作所用的时间,如从 ...
- LR自带网站飞机订票系统 启动
LR自带的网站:飞机订票系统 可是如何启动自带的网站呢?? 一.启动服务:开始-所有程序--HP Software-HP LoadRunner-Samples-Web-Start Web Server ...
- Java版飞机订票系统
关注微信公众号:Worldhello 回复 飞机订票系统 可获得系统源代码并可加群讨论交流 数据结构课程设计题目: [飞机订票系统] 通过此系统可以实现如下功能 ...
- windows API 开发飞机订票系统 图形化界面 (四)
接下来的是录入航班.修改航班信息功能的实现: //录入航班 BOOL EntryFlight(HWND hEntryDlg){ TCHAR szDiscount[]; TCHAR szFare[],s ...
- Loadrunner录制+运行+结果-【飞机订票系统实战】
目录结构: 一.LoadRunner实现订票系统脚本录制 二.Loadrunner实现订票系统IP欺骗(此处可以不设置) 三.Loadrunner运行录制的脚本 四.Load generator配置 ...
- C语言实现-航空订票系统(飞机订票系统)
开发环境:CodeBlocks 开发语言:C 实现功能:登录,订票,退票 数据存储:文本读写 涉及文件: 相关文件下载: 码云:https://gitee.com/ikaros-521/c_pro ...
- windows API 开发飞机订票系统 图形化界面 (二)
首先,用到的数据结构的定义.以及全局变量和函数的声明如下: // Flight.c : 定义应用程序的入口点. // #include "stdafx.h" //订单 typede ...
随机推荐
- 创建python虚拟环境如果速度很慢
conda create -n jjenv python=3.6如果我们这样子创建的话下载速度很慢,那就可以用如下方式,相当于改了下载源. conda create -n jjenv python=3 ...
- js将一篇文章中多个连续的<br>标签替换成两个连续的<br>标签
写本文的目的是今天恰好有一个之前做SEO的同事问我怎样把一篇文章中多个连续的br标签替换成两个连续的br标签,这里就牵涉到SEO层面的问题了. 在做SEO优化的时候,其中有一个需要注意的地方就是尽量减 ...
- dedecms自定义模型内容调用多个Ueditor
关于dedecms后台如何整合百度编辑器(ueditor)网上有很多了,本站就不再赘述了,主要问题是,涉及到如果有内容模型的修改,则按照网络上介绍的方法会发现有BUG.当修改过默认的文章模型或者其他模 ...
- C语言实型常量
实型常量又称实数或浮点数.在C语言中可以用两种形式来表示一个实型常量. 一.小数形式 小数形式的实型常量由两部分组成:数字和小数点.如:0.12.12...12都是合法的实型常量. 二.指数形式 在C ...
- python-简单邮件报警
在scrapy爬虫项目中经常遇到 爬取数据时报错无法及时处理 导致数据爬取不完整 只能先查看log才能发现报错 首先写一个简单的邮件发送模块 """ @file: ema ...
- Linux常用服务器搭建
1.Linux常用服务器构建-ftp服务器 ftp服务器 FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”. 用于Internet上的控制文件 ...
- java小练习
打印99乘法表 因为有9行9列,所有要用两个for循环 int m; for (int i = 1; i < 10; i++) { for (int j = 1; j <= i; j++) ...
- [Swift]LeetCode44. 通配符匹配 | Wildcard Matching
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '? ...
- [Swift]LeetCode934. 最短的桥 | Shortest Bridge
In a given 2D binary array A, there are two islands. (An island is a 4-directionally connected grou ...
- Eclipse工具:常用快捷键记录
Eclipse快捷键: 按键操作 按键作用 输入sysout再按下Ctrl+Space System.out.println() Ctrl+1 当某行出错时时,跳出帮 ...