Collections:
Define Variable as Part of Post-Processors
How to define a variable as part of an extractor post-processor?
✍: FYIcenter.com
You can follow this tutorial to define a variable as part of
an extractor post-processor.
1. Open Get-Exchange-Rate.jmx.
2. Add a post-processor, Regular Expression Extractor, after the "Latest Exchange Rate" HTTP request:
Reference Name: base Regular Expression: "base": *"(...)" Template: $1$ Match No.: 1 Default Value: USD
The above settings define a new variable called "base" with the value from a regular expression match process. "Template: $1$" says to take the value from the first matched group. "Match No.: 1" says to take the value from the first match expression pattern.
3. Save the test plan as Get-Exchange-Rate-2.jmx, and run it.
Assume that we get the following output from the HTTP request
{
"base": "EUR",
"date": "2022-22-22",
"rates": {
"AUD": 1.5532,
"BGN": 1.9558,
"BRL": 3.8403,
"CAD": 1.5024,
"CHF": 1.1613,
"CNY": 7.7881,
...
"USD": 1.1848,
"ZAR": 16.441
}
}
The regular expression extractor will set "base = EUR".
The picture below shows you how to define a variable as part of an extractor post-processor:
⇒ Define Variable as Part of BeanShell
⇐ Define Variable as Part of Test Plan
2018-05-27, 2678🔥, 0💬
Popular Posts:
How to validate domain name format? In order to help your programming or testing tasks, FYIcenter.co...
How to valid UUID/GUID strings? In order to help your programming or testing tasks, FYIcenter.com ha...
How to turn off HTTP response compression in SoapUI? HTTP response compression reduces the data size...
How to convert IPv4 to IPv6 addresses? In order to help your programming or testing tasks, FYIcenter...
What are JMeter command line options? You can get see JMeter command line options by running this co...