How to share saved values between scenarios, different objects

Hi All,

I am trying to figure out how I can pass the token across the scenarios. Here is what I am trying to do.

I have created different scala objects for each scenarios I want to run and then I am running it as a list of scenarios. From the Object 1 I grabbed Xpath value and I am trying to pass it to the next object. For some reason the value in the 2nd object is always empty.

test.ob.Login

object Login {

val LoginHttpPost = http(“Login”)
.post("/post/to/this")
.check(xpath("//input[@value=‘1’]/a").saveAs(“Token”)) //Want to save this token here and then pass it to the next object below (Search Object)

val LoginPostScenario = scenario(“Login”).exec(LoginHttpPost )

}

test.ob.Search

object Search{

val SearchHttpPost = http(“Search”)
.post("/post/to/this")
.formParamMap(Map(“Token” → “${Token}”))

val SearchPostScenario = scenario(“Search”).exec(SearchHttpPost )

}

test.ob.Simulation

class TestSimulation extends Simulation {

val performanceTestScenarios = List(

Login.LoginPostScenario .inject(
atOnceUsers(1,
rampUsersPerSec(1) to 1 during(5 seconds)
),

Search.SearchPostScenario .inject(
atOnceUsers(1,
rampUsersPerSec(1) to 1 during(5 seconds)
)

)

setUp(performanceTestScenarios)
.protocols(httpConf)
.maxDuration(1 minutes)

}

When you launch multiple scenarios in one simulation, they all start at the same time. And each has its own session. The way you have coded your simulation will not allow data to flow between them. You need to create a single scenario with a single injection profile where the scenario contains both calls, in order to enable the first one to pass data to the second.