当前位置:网站首页>JMeter starts from zero (III) -- simple use of regular expressions
JMeter starts from zero (III) -- simple use of regular expressions
2022-07-03 03:53:00 【noobTest】
This paper introduces Jmter When sending a request , A common situation :
Suppose we need to send a request , This request requires a parameter , But this parameter is not fixed , He was the last one who asked to return , And it's different every time I return , What should we do at this time ?
First , We create a HTTP Request , That is, pre request , The method is the same as that introduced in the previous article , Add thread group , establish HTTP request , Add view result tree , Then start

Pictured , This is the result of our pre request , For example, we need to use the one marked in the red box for our next request ID:13010051
First, we create a regular expression extractor in this request

Then return to the result tree just now , Left selection is RegExp Tester, In this way, the view on the right side is more organized , then , image Loadrunner Left and right boundary values , Paste the left and right parameters we need into the text box below , Then we use the part we need (.*?) Instead of

Be careful : Not all of them should be used (.*?) Instead of , Here are the rules :

How to check whether we can get the right value by writing like this ? On the right side of the text box is a test Button , Click to view the sampling results :

It's the same as we expected , Here we are 13010051, Then we paste the contents of the text box into the regular expression sampler .

There's a pit here , It's the template. , Don't write nonsense , Don't forget to write , Here are the following rules :
For example, we need to take values in the following responses :
"HeatPowerPlantID":"A","HeatPowerPlantName":"jmeter test "."HeatPowerPlantID":"B","HeatPowerPlantName":"jmeter test ".
Regular expression extractor template , Style is :$n$.
If the template is :$0$, Is what the entire expression matches , It includes the contents inside and outside the parentheses , The value obtained is the whole content , namely :
"HeatPowerPlantID":"A","HeatPowerPlantName":"jmeter test "."HeatPowerPlantID":"B","HeatPowerPlantName":"jmeter test ".
If the template is :$1$, Then it corresponds to the first (.*?) What matches , namely A
If the template is :$2$, Then it corresponds to the second in the regular expression (.*?) What matches , namely B
If the template is $1$$2$, Then put 2 individual (.*?) The matched content is spliced , namely AB.
Templates can be combined freely , In the following cases .
Now our regular expression is done , How to use the next request , We create the next HTTP request , And add parameters :

The parameters we get a , As the parameter of the next request , The name of this parameter is heatPowerPlantIDs, Its value is in our regular expression a, It is written here as :${a}
So far, parameterization is completed ,PS: comparison loadrunner Parametric Association of ,Jmeter I feel a little troublesome , But the principle is the same , The parameter position is determined by the left and right boundary values , And then take .
Then we click Run , You can see in the result tree , The request is successful , We successfully deleted ID by 13010051 The data of


边栏推荐
- [mathematical logic] predicate logic (first-order predicate logic formula | example)
- SAP UI5 应用开发教程之一百零五 - SAP UI5 Master-Detail 布局模式的联动效果实现明细介绍
- MongoDB簡介
- Is pytorch difficult to learn? How to learn pytorch well?
- 递归:快速排序,归并排序和堆排序
- C语言HashTable/HashSet库汇总
- Nodejs Foundation: shallow chat URL and querystring module
- npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
- [MySQL] the difference between left join, right join and join
- golang xxx. Go code template
猜你喜欢

递归:快速排序,归并排序和堆排序

ffmpeg录制屏幕和截屏

The latest analysis of the main principals of hazardous chemical business units in 2022 and the simulated examination questions of the main principals of hazardous chemical business units

Download and install captura and configure ffmpeg in captura

Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check

简易版 微信小程序开发之for指令、上传图片及展示效果优化

TCP/IP模型中的重磅嘉宾TCP--尚文网络奎哥

小程序获取用户头像和昵称

2022 tea master (intermediate) examination questions and analysis and tea master (intermediate) practical examination video

MongoDB簡介
随机推荐
sigaction的使用
在写web项目的时候,文件上传用到了smartupload,用了new string()进行转码,但是在数据库中,还是会出现类似扑克的乱码
Makefile demo
For instruction, uploading pictures and display effect optimization of simple wechat applet development
Bid farewell to artificial mental retardation: Mengzi open source project team received RMB 100 million financing to help NLP develop
C语言HashTable/HashSet库汇总
递归使用和多维数组对象变一维数组对象
Error in compiled file: error: unmapped character encoding GBK
Basic operations of mongodb [add, delete, modify, query]
What can learning pytorch do?
递归:快速排序,归并排序和堆排序
IPv6过渡技术-6to4手工隧道配置实验--尚文网络奎哥
numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
node,npm以及yarn下载安装
FileZilla client download and installation
FileZilla Client下载安装
基于Pytorch和RDKit的QSAR模型建立脚本
[combinatorics] basic counting principle (addition principle | multiplication principle)
CEPH Shangwen network xUP Nange that releases the power of data
2022 tea master (primary) examination questions and tea master (primary) examination question bank