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 ...
随机推荐
- C/C++ Windows API——获取计算机信息 转
转自:http://blog.csdn.net/chy555chy/article 函数 头文件 作用 GetVersionEx <windows.h> 获取系统版本信息(deprecat ...
- AWS backup
shadowsocks ssserver -c /etc/shadowsocks/config.json start/stop/reset
- sharePoint中简单的父页面跳转子页面代码!
1,SharePoint中挺简单的一个父页面跳转到子页面的Js代码!常常用到,每次都到以前的项目中去找代码,挺麻烦! (1)父页面代码. function imgAddParentclick() { ...
- 用javascript编写猜拳游戏(函数)
const readline = require('readline-sync')//引用readline-sync console.log('欢迎进入猜拳游戏'); //电脑随机出拳 let fn ...
- Centos6_32位系统512M内存_如何安装gogs_Mysql_配置开机自启动
因为有很多人的Linux版本比较低,内存配置也较低,X86 ,32位系统的:所以这里推荐采用二进制安装gogs,并且使用Mysql:这个是傻瓜式的安装方案,适合绝大多数人(提及了centos7的安装思 ...
- linux中删除文件内空白行的几种方法。
linux中删除文件内空白行的几种方法 有时你可能需要在 Linux 中删除某个文件中的空行.如果是的,你可以使用下面方法中的其中一个.有很多方法可以做到,但我在这里只是列举一些简单的方法. 你可能已 ...
- python反射怎么用
反射: 通过字符串的形式对 对象 进行增删改查 setattr 设置某个属性的值 class A(object): def __init__(self): self.name = "sath ...
- php源码建博客4--实现MVC结构微型框架
主要: 常量优化路径 自动加载类 优化入口文件 安全访问项目目录 --------------文件结构:-------------------------------------- blog├─App ...
- 【Hive三】Hive理论
1. Hive基础 1. Hive基础 Hive基本概念 引入原因: Hive是什么 Hive数据管理 四种数据模型 Hive内部表和外部表 Hive数据类型 Hive的优化 Map的优化: Redu ...
- Hive命令行及参数配置
1 . Hive 命令行 输入$HIVE_HOME/bin/hive –H 或者 –help 可以显示帮助选项: 说明: 1. -i 初始化 HQL 文件. 2. -e 从命令行执行指定的 HQL ...