use response of EXISTS on SAVEAS


I’ve a problem with gatling because i want “doIf” something when i CHECK if something is on the page.
For exemple, i want to exec a specific treatment if i found on the page a specific wording because a html block is showed.

[...] .check(substring("Resultat de recherche").exists.saveAs("MyBool"))) .doIf("${MyBool}") { exec([...]) }

But, in MyBool i’ve an integer code, 6938 ! I don’t where they came from and why, exists doesn’t return à boolean we can save it on a varaibel “MyBool” ?



Here is more info:


thank you, it works !
it’s weird because if i do an “exists” before “saveAs” on a variable, the result is wrong but if i saveAs the substring result AND i do the exists like you say on the “doIf”, they work…
Strange things but the principal is to be unstuck :slight_smile:

Hi Herve!

The “exists” in the check is different than the one used in EL and if you omit it, it will be auto-deduced:

If the substring in the response is optional (can occur on not), you can add “.optional” to your check - Gatling won’t fail the request if the string is absent:

check(substring(“Resultat de recherche”).optional.saveAs(“MyBool”)))


Good luck!