How to set global variables and regular expression extractor by jmeter
This article mainly explains "jmeter how to set global variables and regular expression extractor", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "jmeter how to set global variables and regular expression extractor" bar!
In the interface test, many APIs have to take the token after login to send requests normally. Here, record that the login acquisition token is set as a global variable for other APIs to use.
After logging in, there will be a token value in the returned information. Add the regular expression in the post processor to extract token, and then use the BeanShell PostProcessor in the post processor to set token as the global variable.
1. Get the token value:
1.1. grab the bag with fiddler
1.2, F12 view interface information
1.3.Log in to view with jmeter
2. Token is extracted by regular expression:
3. BeanShell PostProcessor sets token as a global variable:
4. Other APIs use this global variable:
Add http header Manager
The regular expression extractor extracts multiple values
The value in the data returned by the previous interface needs to be used in the parameters of the next interface, so the value is obtained through the regular expression extractor.
$1 $, $2 $, $3$ represents the data that matches the first, second and third templates at the same time
Matching number: fill in 1 here, which means that each template value obtains the first matching data.
${id_g1} get the data matched by the first template
${id_g2} get the data matched by the second template
${id_g3} get the data matched by the third template
Thank you for reading, the above is the content of "how jmeter sets global variables and regular expression extractor". After the study of this article, I believe you have a deeper understanding of how jmeter sets global variables and regular expression extractor, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!