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


边栏推荐
- FileZilla client download and installation
- 2022-07-02:以下go语言代码输出什么?A:编译错误;B:Panic;C:NaN。 package main import “fmt“ func main() { var a =
- 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-尚文网络xUP楠哥
- Download and install captura and configure ffmpeg in captura
- [Blue Bridge Road -- bug free code] DS18B20 temperature reading code analysis
- [mathematical logic] propositional logic (equivalent calculus | idempotent law | exchange law | combination law | distribution law | De Morgan law | absorption rate | zero law | identity | exclusion l
- redis在服务器linux下的启动的相关命令(安装和配置)
- [mathematical logic] propositions and connectives (propositions | propositional symbolization | truth connectives | no | conjunction | disjunction | non truth connectives | implication | equivalence)
猜你喜欢

Hutool动态添加定时任务

Appium automated testing framework

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

Role of JS No

Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)

编译文件时报错:错误: 编码GBK的不可映射字符

Web会话管理安全问题

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

docker安装及启动mysql服务

2022 tea master (intermediate) examination questions and analysis and tea master (intermediate) practical examination video
随机推荐
What is pytorch? Is pytorch a software?
Simple wechat applet development page Jump, data binding, obtaining user information, obtaining user location information
[DRM] simple analysis of DRM bridge driver call process
FileZilla Client下載安裝
How does the pytorch project run?
毕设-基于SSM宠物领养中心
递归使用和多维数组对象变一维数组对象
The difference between static web pages and dynamic web pages & the difference between Web1.0 and Web2.0 & the difference between get and post
Use three JS make a simple 3D scene
MySQL MAC download and installation tutorial
Read a paper_ ChineseBert
Hutool动态添加定时任务
[mathematical logic] propositional logic (propositional logic reasoning | formal structure of reasoning | inference law | additional law | simplification law | hypothetical reasoning | refusal | disju
C语言HashTable/HashSet库汇总
2022 mobile crane driver examination registration and mobile crane driver operation examination question bank
Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
错误 C2694 “void Logger::log(nvinfer1::ILogger::Severity,const char *)”: 重写虚函数的限制性异常规范比基类虚成员函数
js中#号的作用
[mathematical logic] propositional logic (equivalent calculus | idempotent law | exchange law | combination law | distribution law | De Morgan law | absorption rate | zero law | identity | exclusion l
Applet get user avatar and nickname