Reputation: 1
I am trying to get a random id item from this session array for the payload:
.payload{session =>
session("ids").as[Array[String]](random.nextInt(
session("ids").as[Array[String]].length))}
This is not working because I cannot get something from the array once I write .as[Array].
I have to use session object in this way, and when I do anything like the following example, it fails because the code isn't synchronous:
.payload{session => {
val data = session("ids").as[Array[String]]
data(random.nextInt(data.length))
}}
How can I get a value from session("ids") in one line, synchronously?
Upvotes: 0
Views: 426
Reputation: 2604
If you're using data
in a call that's processed as Gatling EL, you can just use#{data.random()}
Upvotes: 1