Search code examples
jmeterjmeter-pluginsjmeter-5.0

Extracting JSON and using it in if condition


I need to add a condition in my thread where my next HTTP Request will execute only if the previous response has message message that says 'You can proceed with the booking.'

first response

I tried adding regular expression extractor to get MessageInfo using the below expression.

"MessageInfo": "(.*?)"

I also tried with JSON extractor using below json path expression:

$..MessageInfo

Below is the Expression that i added in if condition:

if condition

However, my execution stops after the first response and does not move into the if condition. Any help would be appreciated.


Solution

  • You need to use a Function or Variable which resolves to true in the If Controller in order to be able to run its children. You're giving a string which isn't equal to true therefore If Controller's children are never run

    Therefore you need to use your expression in i.e. __jexl3() function

    ${__jexl3("${MessageInfo}"=="You can proceed with the booking.",)}
    

    enter image description here

    More information: 6 Tips for JMeter If Controller Usage