方法一:是调用登录接口,在调用登录后的接口

方法二:手动储存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 ;
}

运行日志如下:

log

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种应对方法的更多相关文章

  1. iOS 几种加密方法

    iOS常见的几种加密方法 普通加密方法是讲密码进行加密后保存到用户偏好设置中 钥匙串是以明文形式保存,但是不知道存放的具体位置 1.base64加密 base64 编码是现代密码学的基础 基本原理: ...

  2. Python爬虫突破封禁的6种常见方法

    转 Python爬虫突破封禁的6种常见方法 2016年08月17日 22:36:59 阅读数:37936 在互联网上进行自动数据采集(抓取)这件事和互联网存在的时间差不多一样长.今天大众好像更倾向于用 ...

  3. 浅谈 php 采用curl 函数库获取网页 cookie 和 带着cookie去访问 网页的方法!!!!

    由于近段时间帮朋友开发一个能够查询正方教务系统的微信公众平台号.有所收获.这里总结下个人经验. 开讲前,先吐槽一下新浪云服务器,一个程序里的   同一个函数  在PC测试可以正常运行,在它那里就会挂的 ...

  4. js,java,浮点数运算错误及应对方法

    js,java浮点数运算错误及应对方法 一,浮点数为什么会有运算错误 IEEE 754 标准规定了计算机程序设计环境中的二进制和十进制的浮点数自述的交换.算术格式以及方法. 现有存储介质都是2进制.2 ...

  5. RealSense开发-Session和SenseManager的几种创建方法

    从Intel RealSense 的SDK文档对其架构(如图1所示)的始描述可知,Session是SDK应用的主控模块,必须在所有模块操作之前创建,并且在所有模块注销后最后注销.SenseManage ...

  6. spring与mybatis三种整合方法

    spring与mybatis三种整合方法 本文主要介绍Spring与Mybatis三种常用整合方法,需要的整合架包是mybatis-spring.jar,可通过链接 http://code.googl ...

  7. Android中定时执行任务的3种实现方法

    在Android开发中,定时执行任务的3种实现方法: 一.采用Handler与线程的sleep(long)方法(不建议使用,java的实现方式)二.采用Handler的postDelayed(Runn ...

  8. 【转】asp.net Cookie值中文乱码问题解决方法

    来源:脚本之家.百度空间.网易博客 http://www.jb51.net/article/34055.htm http://hi.baidu.com/honfei http://tianminqia ...

  9. AOP在 .NET中的七种实现方法

    7Approaches for AOP in .Net AOP在 .NET中的七种实现方法 Here are all the ways that I can think of to add AOPto ...

随机推荐

  1. HDU 1006 Tick and Tick(时钟,分钟,秒钟角度问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1006 Tick and Tick Time Limit: 2000/1000 MS (Java/Oth ...

  2. M4修改外部晶振8M和25M晶振的方法

    共计修改三个参数: 1.HSE_VALUE   具体位置在stm32f4xx.h中 2.PLL_M          具体位置在system_stm32f4xx.c中 3.Keil编译器 工程的Opt ...

  3. HDFS Federation(转HDFS Federation(HDFS 联盟)介绍 CSDN)

    转载地址:http://blog.csdn.net/strongerbit/article/details/7013221 HDFS Federation(HDFS 联盟)介绍 1. 当前HDFS架构 ...

  4. angular1的复选框指令--checklistModel

    这个指令可以改变一组checkbox的model格式,提交的时候格式为[x,y,z,...] //复选框指令 .directive('checklistModel', ['$parse', '$com ...

  5. update更新修改数据

    update ---整表更新数据 update  表名  set  需要调整字段1= '值1' ,需要调整字段2= '值2'  …… ---更新条件数据 update  表名  set  需要调整字段 ...

  6. 多用户OFDM系统资源分配研究

    首先,OFDMA 是什么? OFDM 技术的基本原理是将无线信道划分为若干互相正交的子信道,把高速串行数据流转化为低速并行子数据流,低速并行子数据流在子信道上独立传输. OFDMA 是LTE的下行多址 ...

  7. spring-集成redis

    Redis是key-value存储的非关系型数据库.Spring Data Redis包含了多个模板实现,用来完成Redis数据库的数据存取功能 1.如何连接Redis? Spring Data Re ...

  8. php无限级分类----封装函数

    public function catetree($cateRes){//传递过来的数据资源 return $this->sort($cateRes); 调用函数 } public functi ...

  9. Hbase过滤器

    Hbase过滤器简介 HBase的基本API,包括增.删.改.查等,增.删都是相对简单的操作,与传统的RDBMS相比,这里的查询操作略显苍白,只能根据特性的行键进行查询(Get)或者根据行键的范围来查 ...

  10. 最新版的stm32f1xx.h文件中取消了u8, u16, u32的类型定义

    使用芯片stm32f103zet6和stm32l151c8t6,在移植程序时发现,编译器提示u8未定义: 在Keil MDK 开发环境里,st定义无符号32位整形数据有很多种表示方法: 1 unsig ...