当前位置:网站首页>JMeter做接口测试,如何提取登录Cookie
JMeter做接口测试,如何提取登录Cookie
2022-07-06 06:07:00 【测试界的飘柔】
用JMeter进行接口测试时,经常需要通过登录接口提取Cookie才能进行其他业务流程,如果cookie/token是在登录请求的响应报文里,那么可以通过正则表达式直接提取出来,但是如果Cookie不是在响应报文里,还可以怎么提取出来呢?
通过分析发现,业务接口的请求头中带有Cookie值,需要通过登录接口获取Cookie后传递到其它接口的请求头中。
给带重定向的登录接口添加HTTP Cookie Manger,可以看到请求体里的Cookie值。

要将Cookie存储为变量,首先需要先将/bin目录下jmeter.properties文件的“#CookieManager.save.cookies=false”修改为“CookieManager.save.cookies=true”且去掉注释“#”。


在登录接口下添加HTTP Cookie管理器,并添加用户定义的Cookie,这里设置名称为aaa,值为${COOKIE_aaa}。

在HTTP请求头管理器中,给需要用到这个Cookie值的地方用${COOKIE_aaa}表示,即为:

在后续请求中,都可以看到请求头中带有传递的Cookie值。
最后: 可以在公众号:伤心的辣条 ! 自行领取一份216页软件测试工程师面试宝典文档资料【免费的】。以及相对应的视频学习教程免费分享!,其中包括了有基础知识、Linux必备、Shell、互联网程序原理、Mysql数据库、抓包工具专题、接口测试工具、测试进阶-Python编程、Web自动化测试、APP自动化测试、接口自动化测试、测试高级持续集成、测试架构开发测试框架、性能测试、安全测试等。
我推荐一个【Python自动化测试交流群:746506216】,大家可以一起探讨交流软件测试,共同学习软件测试技术、面试等软件测试方方面面,助你快速进阶Python自动化测试/测试开发,走向高薪之路。
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
边栏推荐
- isam2运行流程
- 数字三角形模型 AcWing 1015. 摘花生
- Reading notes of effective managers
- CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
- [Baiwen smart home] first day of the course_ Learn Embedded and understand the development mode of bare metal and RTOS
- [C language syntax] the difference between typedef struct and struct
- C language learning notes (mind map)
- Linux regularly backs up MySQL database
- HCIA复习
- 【论文阅读】NFlowJS:基于鲁棒学习的合成负数据密集异常检测
猜你喜欢

Application du Groupe Li dans gtsam

Function of activation function

Report on the competition status and investment decision recommendations of Guangxi hospital industry in China from 2022 to 2028

Network protocol model

What are the test sites for tunnel engineering?

进程和线程的理解

单元测试的意义

Investment strategy discussion and market scale prediction report of China's solid state high power amplifier industry from 2022 to 2028

IP day 16 VLAN MPLS configuration

Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
随机推荐
JDBC Requset 对应内容及功能介绍
[paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning
10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
MPLS test report
Postman核心功能解析-参数化和测试报告
数学三大核心领域概述:几何
[untitled]
2022 software testing workflow to know
Application of Lie group in gtsam
Idea new UI usage
Function of activation function
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Title 1093: character reverse order
Clock in during winter vacation
LeetCode 731. 我的日程安排表 II
Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
Manhattan distance and Manhattan rectangle - print back font matrix
Gtest之TEST宏的用法
[course notes] Compilation Principle
MySQL之数据类型