Jmeter IF controller - example
If controller example to control which request to send based on response of the other sampler.
We’re using Dummy Sampler to generate requests.
We also need to extract response’s code. We can use Regular Expression Extractor to get it:
- Field to check: Response Code
- Reference Name: RESPONSE_CODE
- Regular Expression: (\d+)
- Template $1$
First If Controller condition
${RESPONSE_CODE}!="200"
Second If Controller condition:
${RESPONSE_CODE}=="200"
Setup Dummy Sampler to return code 200.
Result:
And now edit it to return something other than 200
Result:
Comparing variables
In case you want to compare string variables you need to enclose them in quotes
"${my_variable}"=="foo"