问题
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