loadrunner_遇到cookie接口_3种应对方法
方法一:是调用登录接口,在调用登录后的接口
方法二:手动储存cookie,写死cookie
方法一:提前登录收集cookie,写成参数化文件
方法一,案例(就是先登录,再写登录后的接口);
注:userName也可以做成文件参数化的方式
Action()
{ //先登录login接口,由于loadrunner也是基于浏览器形式的,所以也会储存cookie
web_custom_request("post_cokies", "Method=POST", "URL=http://localhost:8080/pinter/bank/api/login", "Body=userName=admin&password=1234", "TargetFrame=", LAST ); //这是登录后的接口,查询余额的
web_url("query", "URL=http://localhost:8080/pinter/bank/api/query?userName=admin", LAST ); return ;
}
运行日志如下:
Virtual User Script started at : -- ::
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0. for WINXP; build (Aug ::) [MsgId: MMSG-]
Run Mode: HTML [MsgId: MMSG-]
Run-Time Settings file: "C:\script\0224\cookie\\default.cfg" [MsgId: MMSG-]
Ending action vuser_init.
Running Vuser...
Starting iteration .
Starting action Action.
Action.c(): t=1224ms: -byte response headers for "http://localhost:8080/pinter/bank/api/login" (RelFrameId=, Internal ID=)
Action.c(): HTTP/1.1 \r\n
Action.c(): Set-Cookie: testfan-id=76e4a2de-8dbd--bbd7-728b39bd58d8; Max-Age=; Expires=Tue,
Action.c(): -Mar- :: GMT; Path=/\r\n
Action.c(): Content-Type: application/json;charset=UTF-\r\n
Action.c(): Transfer-Encoding: chunked\r\n
Action.c(): Date: Sun, Mar :: GMT\r\n
Action.c(): \r\n
Action.c(): t=1398ms: -byte chunked response overhead for "http://localhost:8080/pinter/bank/api/login" (RelFrameId=, Internal ID=)
Action.c(): 2c\r\n
Action.c(): t=1402ms: -byte chunked response overhead for "http://localhost:8080/pinter/bank/api/login" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): \r\n
Action.c(): \r\n
Action.c(): t=1409ms: -byte chunked response body for "http://localhost:8080/pinter/bank/api/login" (RelFrameId=, Internal ID=)
Action.c(): {"code":"","message":"success","data":null}
Action.c(): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://localhost:8080/pinter/bank/api/login" [MsgId: MMSG-]
Action.c(): web_custom_request("post") was successful, body bytes, header bytes, chunking overhead bytes [MsgId: MMSG-]
Action.c(): t=1930ms: -byte response headers for "http://localhost:8080/pinter/bank/api/query?userName=beihe" (RelFrameId=, Internal ID=)
Action.c(): HTTP/1.1 \r\n
Action.c(): Content-Type: application/json;charset=UTF-\r\n
Action.c(): Transfer-Encoding: chunked\r\n
Action.c(): Date: Sun, Mar :: GMT\r\n
Action.c(): \r\n
Action.c(): t=2108ms: -byte chunked response overhead for "http://localhost:8080/pinter/bank/api/query?userName=beihe" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): t=2173ms: -byte chunked response overhead for "http://localhost:8080/pinter/bank/api/query?userName=beihe" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): \r\n
Action.c(): \r\n
Action.c(): t=2310ms: -byte chunked response body for "http://localhost:8080/pinter/bank/api/query?userName=beihe" (RelFrameId=, Internal ID=)
Action.c(): {"code":"","message":"success","data":"$ 10,163,749"}
Action.c(): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://localhost:8080/pinter/bank/api/query?userName=beihe" [MsgId: MMSG-]
Action.c(): web_url("query") was successful, body bytes, header bytes, chunking overhead bytes [MsgId: MMSG-]
Ending action Action.
Ending iteration .
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
log
方法二,案例(通过浏览器抓包,手动设置cookie的方法)
1.”火狐“ 浏览器清空以前的cookie
2.进行登录操作F12抓包
3.查看响应cookie
4.在loadrunner中添加 这个函数
web_add_cookie ("key=value; domain=ip不加端口");
web_add_cookie ("testfan-id=f9325d71-f9a1-46a4-bc35-1c760a94b464; domain=localhost");
注: cookie也可以做成文件参数化的形式
Action()
{ // //先登录login接口,由于loadrunner也是基于浏览器形式的,所以也会储存cookie
// web_custom_request("post_cokies", "Method=POST",
//
// "URL=http://localhost:8080/pinter/bank/api/login",
//
// "Body=userName=admin&password=1234",
//
// "TargetFrame=",
//
// LAST );
// //这是手动抓包抓取的cookie 信息,添加在前面就可以了。
web_add_cookie ("testfan-id=f9325d71-f9a1-46a4-bc35-1c760a94b464; domain=localhost"); //这是登录后的接口,查询余额的
web_url("query", "URL=http://localhost:8080/pinter/bank/api/query?userName=admin", LAST ); return ;
}
运行日志如下:
Virtual User Script started at : -- ::
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0. for WINXP; build (Aug ::) [MsgId: MMSG-]
Run Mode: HTML [MsgId: MMSG-]
Run-Time Settings file: "C:\test_huzhenyu\Script\cokies2\\default.cfg" [MsgId: MMSG-]
Ending action vuser_init.
Running Vuser...
Starting iteration .
Starting action Action.
Action.c(): web_add_cookie was successful [MsgId: MMSG-]
Action.c(): t=861ms: -byte response headers for "http://localhost:8080/pinter/bank/api/query?userName=hu" (RelFrameId=, Internal ID=)
Action.c(): HTTP/1.1 \r\n
Action.c(): Content-Type: application/json;charset=UTF-\r\n
Action.c(): Transfer-Encoding: chunked\r\n
Action.c(): Date: Sat, Mar :: GMT\r\n
Action.c(): \r\n
Action.c(): t=897ms: -byte chunked response overhead for "http://localhost:8080/pinter/bank/api/query?userName=hu" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): t=903ms: -byte chunked response overhead for "http://localhost:8080/pinter/bank/api/query?userName=hu" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): \r\n
Action.c(): \r\n
Action.c(): t=918ms: -byte chunked response body for "http://localhost:8080/pinter/bank/api/query?userName=hu" (RelFrameId=, Internal ID=)
Action.c(): {"code":"","message":"success","data":"$ 81,715,804"}
Action.c(): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://localhost:8080/pinter/bank/api/query?userName=hu" [MsgId: MMSG-]
Action.c(): web_url("query") was successful, body bytes, header bytes, chunking overhead bytes [MsgId: MMSG-]
Ending action Action.
Ending iteration .
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
方法三,案例(提前登录收集cookie,写成参数化文件)
Action()
{ // loadrunner和浏览器一样,会自动处理cookie // web_custom_request("post", "Method=POST",
//
// "URL=http://localhost:8080/pinter/bank/api/login",
//
// "Body=userName={user}&password=1234",
//
// "TargetFrame=",
//
// LAST );
//{cookie} 取的是文件参数化的值
web_add_cookie ("testfan-id={cookie}; domain=localhost"); web_url("query",
//{uesr}取得也是文件中的参数化的值 "URL=http://localhost:8080/pinter/bank/api/query?userName={user}", LAST ); return ;
} 文件参数化-->操作步骤 --> 如下 user,cookie admin,cookie参数 dev,cookie参数值 test,cookie参数值 设置成 uesr,cookie 抓包收集的
loadrunner_遇到cookie接口_3种应对方法的更多相关文章
- iOS 几种加密方法
iOS常见的几种加密方法 普通加密方法是讲密码进行加密后保存到用户偏好设置中 钥匙串是以明文形式保存,但是不知道存放的具体位置 1.base64加密 base64 编码是现代密码学的基础 基本原理: ...
- Python爬虫突破封禁的6种常见方法
转 Python爬虫突破封禁的6种常见方法 2016年08月17日 22:36:59 阅读数:37936 在互联网上进行自动数据采集(抓取)这件事和互联网存在的时间差不多一样长.今天大众好像更倾向于用 ...
- 浅谈 php 采用curl 函数库获取网页 cookie 和 带着cookie去访问 网页的方法!!!!
由于近段时间帮朋友开发一个能够查询正方教务系统的微信公众平台号.有所收获.这里总结下个人经验. 开讲前,先吐槽一下新浪云服务器,一个程序里的 同一个函数 在PC测试可以正常运行,在它那里就会挂的 ...
- js,java,浮点数运算错误及应对方法
js,java浮点数运算错误及应对方法 一,浮点数为什么会有运算错误 IEEE 754 标准规定了计算机程序设计环境中的二进制和十进制的浮点数自述的交换.算术格式以及方法. 现有存储介质都是2进制.2 ...
- RealSense开发-Session和SenseManager的几种创建方法
从Intel RealSense 的SDK文档对其架构(如图1所示)的始描述可知,Session是SDK应用的主控模块,必须在所有模块操作之前创建,并且在所有模块注销后最后注销.SenseManage ...
- spring与mybatis三种整合方法
spring与mybatis三种整合方法 本文主要介绍Spring与Mybatis三种常用整合方法,需要的整合架包是mybatis-spring.jar,可通过链接 http://code.googl ...
- Android中定时执行任务的3种实现方法
在Android开发中,定时执行任务的3种实现方法: 一.采用Handler与线程的sleep(long)方法(不建议使用,java的实现方式)二.采用Handler的postDelayed(Runn ...
- 【转】asp.net Cookie值中文乱码问题解决方法
来源:脚本之家.百度空间.网易博客 http://www.jb51.net/article/34055.htm http://hi.baidu.com/honfei http://tianminqia ...
- AOP在 .NET中的七种实现方法
7Approaches for AOP in .Net AOP在 .NET中的七种实现方法 Here are all the ways that I can think of to add AOPto ...
随机推荐
- CSU - 1224 ACM小组的古怪象棋
传送门: http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1224 1224: ACM小组的古怪象棋 Lime Limit: 1 Sec ...
- Lua库-bit32库
Global = Global or {}; local bits = {}; function bits.bxor(num1,num2) local ret=bit32.bxor(num1,num2 ...
- jquery仿移动端支付宝键盘
最近做项目时碰到一个需求,就是在移动端支付页面点击支付按钮弹出一个支付键盘,类似于支付宝的那种.由于项目只是单纯的手机网站,而并非app,所以这个功能得由前端来实现.话不多说,先上图看看效果. 尼玛, ...
- tomcat安装、配置相关的几个点
Connector port="8080"HTTP协议的默认端口号:8080 FTP协议的默认端口号:21 1.tomcat的安装目录要与Java jre的安装目录一致. bin: ...
- yii学习笔记(3),自定义全局工具函数
在平时开发是经常需要打印数据来调试 常见的打印方式有print_r和var_dump,但是这样打印出来格式很乱不好浏览 在打印函数前后加上<pre></pre>就可以将内容原样 ...
- Hive的内置函数
定义: UDF(User-Defined-Function),用户自定义函数对数据进行处理. UDTF(User-Defined Table-Generating Functions) 用来解决 输入 ...
- PHP array_reduce()函数的应用解析
实例 向用户自定义函数发送数组中的值,并返回一个字符串: <?php function myfunction($v1,$v2) { return $v1 . "-" . $v ...
- 反射之三种class对象的获取方法
package www.bit.tech; public class Fanshe1 { } package www.bit.tech; import www.bit.tech.Fanshe1; cl ...
- 20145234黄斐《信息安全系统设计基础》第八周(Linux下vim相关命令)
Linux下vim相关命令 在编辑程序时经常使用vim,所以记住一些常用的指令还是很有必要的 文件命令 vim file 打开单个文件vim file vim file1 file2 file3 .. ...
- 20145234黄斐《信息安全系统设计基础》第七周(Linux命令复习)
已经到了11月,学期过半,而<信息安全系统设计基础>这门课也要到了期中考试了.所以,我在这里,对前半个学期的最基础的知识,做一个复习 复习计划分为两步,本次为Linux命令,下次计划复习g ...