Pass session variables between 2 scenarios

Hello,

I have 2 scenarios scn1 scn2, in scn1 in the response, I want to save the the ID of the message so that I can check it in the second scenario. However I was not able to pass this message_id session into the second scenario. Can anyone help me for this case?

val scn1 = scenario(“Test1”)
.exec(tcil(“TYBMSG_Message”).requestReply
.message(ByteArrayBody(_ => {
val convId = newConversationId
val text = String.format(TYBMSG_Message(), generationTime(), convId, newDcxId(), convId)
print(text)
decodeIATB(text).getBytes(UTF_8)
}))
.check(regex(""“TXT+ID\:(.*?)’”"")
.saveAs(“message_id”))
)

val scn2 = scenario(“Test2”)
.exec(tcil(“MDASUQ_Message”).requestReply
.message(ByteArrayBody(_ => {
val convId = newConversationId
val text = String.format(MDASUQ_Message(), generationTime(), convId, newDcxId(), convId)
print(text)
decodeIATB(text).getBytes(UTF_8)
}))
.check(
substring("${message_id}")
))

setUp(scn1.inject(atOnceUsers(1))
.protocols(msxPDT),
scn2.inject(atOnceUsers(1))
.protocols(ttfPDT))

You can combine Chain Builders (.exec) in a Scenario Builder in that case they will be in one session. Also you can separate Chain Builders to separate object.

val scn1 =
.exec(tcil(“TYBMSG_Message”).requestReply
.message(ByteArrayBody(_ => {
val convId = newConversationId
val text = String.format(TYBMSG_Message(), generationTime(), convId, newDcxId(), convId)
print(text)
decodeIATB(text).getBytes(UTF_8)
}))
.check(regex(""“TXT+ID\:(.*?)’”"")
.saveAs(“message_id”))
)

val scn2 =
.exec(tcil(“MDASUQ_Message”).requestReply
.message(ByteArrayBody(_ => {
val convId = newConversationId
val text = String.format(MDASUQ_Message(), generationTime(), convId, newDcxId(), convId)
print(text)
decodeIATB(text).getBytes(UTF_8)
}))
.check(
substring("${message_id}")
))

val CompleteScen: ScenarioBuilder = scenario(“SCENARIO::SOME SCENARIO”)

  .exec(session => {

   session.set("value", "myvalue")
  })

  .exec(scn1, scn2)