How to pass correlated value in next request in Gatling script

久未见 提交于 2020-06-01 05:09:50

问题


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()))
}

回答1:


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()))


来源:https://stackoverflow.com/questions/62113261/how-to-pass-correlated-value-in-next-request-in-gatling-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!