Search code examples
scalaunix-timestampgatling

How to pass correlated value in next request in Gatling script


How can I replace "details1" in "request_2" with correlated value "SynchToken" from "request_1". I am trying to replace with ${SynchToken} but it is not reflecting the correlated value.

val Transaction_Name_1 = group("Transaction_Name_1") {
  exec(http("request_1")
    .get(session => "/abc/details1?_=" + System.currentTimeMillis())
    .check(regex("""name="SYNCHRONIZER_TOKEN" value="(.*?)"""").saveAs("SynchToken")))
  .pause(5)
  .exec(http("request_2")
    .get(session => "/abc/details1?_=" + System.currentTimeMillis()))
}

Solution

  • You should really spend some time reading the documentation. Here, you need to use the Session API.

    exec(http("request_2")
        .get(session => "/abc/" + session("SynchToken").as[String] + "?_=" + System.currentTimeMillis()))