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

方法二:手动储存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. stm32函数库分析

    1.STM32F10x_StdPeriph_Lib_V3.5.0  是库函数的全称 2.libraries里面包含的是函数库.C和.H以及CMSIS部分 3.Project里面包含针对MCU各个模块的 ...

  2. CSS3-阴影参数基础

    box-shadow 语法:text-shadow: x-shadow y-shadow distance color; 值  描述  x-shadow  必需.水平阴影的位置.允许负值. y-sha ...

  3. Crash for small compressed texture on some Android device

    I created a full white texture with 4x4 size. Unity requires that compressed texture size should be ...

  4. parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not e

    控制台异常: parsing XML document from class path resource [applicationtext.xml]; nested exception is java ...

  5. JQuery制作网页——第五章 初识 jQuery

    1.jQuery简介: ● jQuery由美国人John Resig于2006年创建 ● jQuery是目前最流行的JavaScript程序库,它是对JavaScript对象和函数的封装 ● 它的设计 ...

  6. SQL语言简单总结

    常用的Sql语言总结: 1. create datebase  datebaseName         //创建数据库 2. drop datebase  datebaseName    //    ...

  7. angularjs中控制器之间的通信----$on、$emit和$broadcast解析

    $on.$emit和$broadcast使得event.data在controller之间的传递变的简单. $emit只能向parent controller传递event与data $broadca ...

  8. Macbook下安装memcached

    参考文献: https://blog.csdn.net/weixin_41827162/article/details/82049520 感谢大佬 安装memcached需要Homebrew 注意点: ...

  9. 解决应用程序无法正常启动0xc0150002等问题

    1.在程序运行出错的时候,右键“我的电脑”,然后点击“管理”→“事件查看器”→“Windows 日志”→“应用程序”,查看错误信息: 1> “E:\IPCam_share\ARP\數據處理\Hg ...

  10. Chip-seq peak annontation

    Chip-seq peak annontation Chip-seq peak annontation PeRl narrowPeak/boardPeak narrowPeak/boardPeak 是 ...