Reputation: 21
I'm new to Gatling and Scala, and would appreciate some advice. Using the following code:
.check(
regex(""""childClientIds":\["([^]]*)"""")
.find
.transform(_.split("""\",\"""").map(_.trim).toSeq)
.saveAs("ChildClientIDs")
)
I've managed to save a list of IDs to the session variable ChildClientIDs. From the Gatling log:
Session(Dashboard,1,Map(ChildClientIDs -> WrappedArray(ID1, ID2, ID3, etc.
How can I access the individual elements in ChildClientIDs and use them in a request? ${ChildClientIDs}
will drop the entire array into the request, as expected. How can I just use the nth element in the array? ${ChildClientIDs}[n]
and ${ChildClientIDs[n]}
don't do the trick.
Upvotes: 0
Views: 4614
Reputation: 21
I think I've answered my own question.
Per the documentation https://docs.gatling.io/reference/script/core/session/el/, ${ChildClientIDs(n)}
is the way to go.
Upvotes: 2
Reputation: 575
If you don't want to use EL, for whatever reason, you can try this :
session => session("ChildClientIDs").as[Seq[String]].apply(indexOfElement)
Upvotes: 0