Search code examples
scalagatlingscala-gatling

regex check and proceed next call


Iam new to gatling and scala. I was trying to validate regex in galting-scala. My scenario. from the response capture (regex) X values, If available then execute step-ABC If X value of component not found, ignore step_ABC


Solution

  • Your example uses .exists, which asserts that the regex must be matched and returns a boolean, not the value of the match. So the "logoId" session variable will always get set, but won't have any data useful for making a subsequent request. Additionally, since the logo is optional in your case, you don't want the scenario failing if it isn't there.

    Optional checks and the gatling EL support your use-case.

    .exec(
       http("get merchant") 
       .get("some url")
       .check(
         regex(""""logoId":(.+?),""").optional.saveAs("logoId")
       )
       .doIf("${logoId.exists()}") {
         exec(...)
       }