if-else block in JMeter -
i expect 2 possible cases in application: search successful , search failed. in both cases have 2 different sets of http requests, jmeter should execute. how can implement if-else block in jmeter scenario? i've tried use if controller regular expression extractor, relying on results of debug sampler, kind of extractors doesn't attached current thread. hence, 1 thread can override result of thread. bug or feature? there workarounds?
my regular expression extractor:
my first if controller:
my second if controller:
order of execution:
always fires first controller , never second. when customer search failed, page not contains word "daniel" , expect ${customer_name} 0 length. moreover, debug sampler returns customer_name filled value after unsuccessful search. looks other thread overrides , extractor not thread safe.
your second condition flaky.
for instance have ${foo} variable. if not set, it's value ${foo}
(surprisingly) , it's length 6.
so if there no match "${customer_name}".length
value 16.
i suggest changing 2nd if controller condition like:
${__javascript(vars.get('customer_name')==null,)}
and should work way. (you need use __javascript() function access vars
object shorthand jmetervariables instance)
another option marking sampler failed in case of "daniel" not found , use ${jmeterthread.last_sample_ok}
variable value condition.
see how use jmeter's 'if' controller , pie. guide if controller tips , tricks.
Comments
Post a Comment