Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter if controller on HTTP response code

Tags:

jmeter

I would like for some branch of the test to execute only if the response code from a previous sample returns with a certain HTTP code 200.

I tried the following as the condition to the 'if controller':

"{httpCode}"== "200"

but no luck (and no luck debugging it, debug sampler says nothing)

Thanks

like image 220
JRun Avatar asked Aug 09 '26 02:08

JRun


1 Answers

Did you extract response code to variable httpCode beforehand? Use regex extractor for it http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor

Then check value of variable like that:

${__javaScript(${httpCode}=="200")} 

Alternatively, you may use assertion, see https://stackoverflow.com/a/11669393/808594

like image 70
F2nd Avatar answered Aug 11 '26 05:08

F2nd