当前位置:网站首页>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自动化测试/测试开发,走向高薪之路。
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
边栏推荐
- Database: ODBC remote access SQL Server2008 in oracel
- 【Postman】Collections-运行配置之导入数据文件
- Nodejs realizes the third-party login of Weibo
- [postman] dynamic variable (also known as mock function)
- The usage and difference between strlen and sizeof
- Overview of three core areas of Mathematics: geometry
- 【API接口工具】postman-界面使用介绍
- IDEA 新UI使用
- P问题、NP问题、NPC问题、NP-hard问题详解
- LeetCode 739. 每日温度
猜你喜欢

【论文代码】SML部分代码阅读

Novice entry SCM must understand those things

Gtest之TEST宏的用法

单元测试的意义

ESP32 ESP-IDF看门狗TWDT

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

Manhattan distance and Manhattan rectangle - print back font matrix

LeetCode 739. 每日温度

Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
![Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)](/img/2c/43ce298794589c5282edda94161d62.jpg)
Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)
随机推荐
10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
Reading notes of effective managers
Accélération de la lecture vidéo de l'entreprise
[postman] test script writing and assertion details
Application of Lie group in gtsam
The latest 2022 review of "graph classification research"
Seven imperceptible truths in software testing
C language learning notes (mind map)
【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
【课程笔记】编译原理
[postman] dynamic variable (also known as mock function)
[happy Spring Festival] if you feel happy, dance
GTSAM中李群的运用
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
曼哈顿距离和-打印菱形
[web security] nodejs prototype chain pollution analysis
[course notes] Compilation Principle
Linux regularly backs up MySQL database
请求转发与重定向
Clock in during winter vacation