Reputation: 1494
I am currently using Gatling and I have a scenario whereby I perform a number of GET requests and depending on the body of the responses I would like to perform a different scenario.
I have this at the moment that doesn't appear to work as expected -
val repeatSpin = scenario("repeatScenario1").repeat(10) {
exec(
scenario1
)
.doIf(bodyString => bodyString.equals("<SwitchEvent/>")){
exec(scenario2)
}
}
What am I doing wrong?
Upvotes: 2
Views: 3550
Reputation: 329
It looks like you've got the .doIf
parameters wrong - it either takes a key in the session and the value you expect, like:
.doIf("${bodyString}", "<SwitchEvent/>") { myChain }
Or, an Expression[Boolean]
- the argument you get is the session
; to get values out of a session you do something like session("bodyString").as[String]
. So, passing a function to the doIf
could look like
.doIf(session => session("bodyString").as[String].equals("<SwitchEvent/>")) { myChain }
Upvotes: 2