当前位置:网站首页>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


边栏推荐
- Download and install node, NPM and yarn
- [Blue Bridge Road -- bug free code] interpretation of some codes of matrix keyboard
- [MySQL] the difference between left join, right join and join
- Dynamic programming: longest common substring and longest common subsequence
- Open Visual Studio 2010 hangs when opening a SQL file sql file
- 小程序获取用户头像和昵称
- Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi
- The difference between static web pages and dynamic web pages & the difference between Web1.0 and Web2.0 & the difference between get and post
- 如何迈向IPv6之IPv6过渡技术-尚文网络奎哥
- 错误 C2694 “void Logger::log(nvinfer1::ILogger::Severity,const char *)”: 重写虚函数的限制性异常规范比基类虚成员函数
猜你喜欢

递归:深度优先搜索

Mysql Mac版下载安装教程
![Mongodb replication set [master-slave replication]](/img/2c/8030548455f45fa252062dd90e7b8b.png)
Mongodb replication set [master-slave replication]

Makefile demo

2022 polymerization process examination questions and polymerization process examination skills

IPv6 transition technology-6to4 manual tunnel configuration experiment -- Kuige of Shangwen network

Is pytorch open source?

numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences

Hutool dynamically adds scheduled tasks

Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
随机推荐
CEPH Shangwen network xUP Nange that releases the power of data
Recursion: depth first search
Half of 2022 is over, so we must hurry up
Read a paper_ ChineseBert
2022年已过半,得抓紧
Arlo's thinking about himself
Dynamic programming: Longest palindrome substring and subsequence
Applet get user avatar and nickname
简易版 微信小程序开发之for指令、上传图片及展示效果优化
Numpy warning visibledeprecationwarning: creating an ndarray from ragged needed sequences
FileZilla Client下載安裝
毕设-基于SSM宠物领养中心
[DRM] simple analysis of DRM bridge driver call process
Wechat applet + Alibaba IOT platform + Hezhou air724ug build a serverless IOT system (III) -- wechat applet is directly connected to Alibaba IOT platform aliiot
Ffmpeg download and installation tutorial and introduction
Is pytorch open source?
如何迈向IPv6之IPv6过渡技术-尚文网络奎哥
Recursion: quick sort, merge sort and heap sort
[mathematical logic] propositional logic (equivalent calculus | idempotent law | exchange law | combination law | distribution law | De Morgan law | absorption rate | zero law | identity | exclusion l
docker安装及启动mysql服务