当前位置:网站首页>【jmeter】實現介面關聯的兩種方式:正則表示式提取器和json提取器
【jmeter】實現介面關聯的兩種方式:正則表示式提取器和json提取器
2020-11-06 01:18:05 【itread01】
關聯通俗來講就是把上一次請求的返回內容中的部分截取出來儲存為引數,用來傳遞給下一個請求使用。
示例:
1.使用者密碼進行登入,登入後生成authentication
2.需要將登入介面響應結果中authentication的作為一個引數,傳給下一個介面
如下圖,需要提取登入介面返回的authentication傳遞給下一個預約訂單列表介面header中
一、使用正則表示式提取器實現介面關聯
1.新增方式:在需要獲取資料的請求上(該場景中為登入介面) 右鍵-->後置處理器--> 選擇正則表示式提取器
引數說明:
引用名稱:即下一個請求要引用的引數名稱,如填寫authentication,則可用${ authentication}引用它。
正則表示式:()括起來的部分就是要提取的。.代表任意字元,+表示一次或多次,*代表出現任意次。(具體正則表示式規則可百度)
模板:用$$引用起來,如果在正則表示式中有多個正則表示式,則可以是$2$,$3$等等,表示解析到的第幾個值給authentication。本處只有1個,所有使用$1$。
匹配數字:0代表隨機,-1代表所有,其餘正整數代表將在檢查的內容中,第幾個匹配的內容提取出來。
2.在後面的介面中使用${authentication}引用
二、使用json提取器實現介面關聯
使用場合:介面關聯,當前一個介面返回的資料型別為json格式的資料,需要從返回的json資料中提取資料。
1.新增方式:在需要獲取資料的請求上(該場景中為登入介面) 右鍵-->後置處理器--> 選擇JSON提取器
引數說明:
Name of created varialies:即下一個請求要引用的引數名稱,如填寫authentication,則可用${ authentication}引用它。
JSON Path expressions:填寫jsonpath,格式:$. 節點名稱 根節點用 “.” 表示
Match Numbers:0代表隨機,-1代表所有,其餘正整數代表將在檢查的內容中,第幾個匹配的內容提取出來。
Default Values:找不到時預設值,一般設定為NOT FOUND
Compute concatenation var(suffix_ALL):是否統計所有,即將匹配到的所有值儲存,名為“變數名_ALL”
2.替換變數為${ 變數名}
三、返回複雜json資料的提取
例如獲取陣列型別的資料:第二個item中第一個hospTags中name值,可以先在察看結果樹種選擇Json Path Tester檢視返回的相應資料,Json Path Expression輸入需要通過jsonpath方式獲取的值點選Test檢查結果是否正確
新增方式:右鍵-->後置處理器--> 選擇JSON提取器
版权声明
本文为[itread01]所创,转载请带上原文链接,感谢
https://www.itread01.com/content/1604495046.html
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World