当前位置:网站首页>JMeter takes the result of the previous request as the parameter of the next request

JMeter takes the result of the previous request as the parameter of the next request

2022-06-27 03:17:00 Xiao Han's daily life

The project interface needs to send a request with token value , Therefore, this article introduces jmeter Operation method that takes the result of the previous request as the parameter of the next request .

1、 New thread group ; Create a new thread under thread group HTTP Request to get token; Create a new view result tree to view the interface request status ;

 

 

2、 complete 【HTTP request 】 Set up , Send a request , see 【 Look at the fruit tree 】 Response data of the page ; 

Format it as follows

3、 stay 【 Look at the fruit tree 】 Regular expression test under the page , Pictured above , The data we want is { "data":" What we want token"}

4、 Use regular expressions to extract what you want

"data":"(.+?)"

(): The enclosed part is to be extracted 
.: A dot denotes matching division “\n” Any single character other than .(\n Represents a newline character )
+:+ Sign means to match the previous character ,1 Times or more ( Here to fill out * It's fine too )
?: Non greedy mode , Find a matching data and stop ; Greedy mode , Get rid of ? The number is OK , It means to extract all the matching data 

Match count: 1  --- Indicates that there is a value for the matching addition 
Match[1][1] = xxxxxxxxx      --- Indicates that the first value obtained is xxxxxx

 If multiple values are obtained , The expression is as follows 
Match[2][1] =             ----- Take the second value 
Match[3][1] =             ----- The third value obtained 

5、 add to 【 Post Processors 】--【 Regular expression extractor 】

 Quote name :   Is the name of the custom variable to be referenced by the next request ;
 Regular expressions :   Is to extract the regular expression of what you want , Can combine   Look at the fruit tree   Under the   Regular tests   To write ;
 Templates :   Is to use the extracted value . Because there may be multiple values matching , So use templates . from  1  Begin to match , By analogy . There's only one , So fill in  $1$  that will do ; according to   Look at the fruit tree   Under the   Regular tests   Back to Match Value filling 
 Match the Numbers (0 For random ):  0  Represents a random value ,1  Represents all values . There's only one , fill  1  that will do ;
 The default value :  Indicates that the parameter has no value , Give it a value . Generally, it is not filled in or null

6、 The newly added 【HTTP request 】( need token), To verify that

 7、 complete http After requesting the content of the page , add to 【HTTP Header Manager 】 To add token

 8、 Create a new view result tree running thread , View results

Successfully transferred obtain token Interface token To use

-------------

This article does not provide When the regular expression extractor needs to extract multiple values , Follow up  

原网站

版权声明
本文为[Xiao Han's daily life]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270301023389.html