Difficulties with saving random value to a separate variable from Vector

Greetings everyone,

I’m trying to randomize my test by extracting available IDs from Json and using some random ID in next requests. As ${ID.random()} picking random ID every time it’s being called i figured i need to make some manipulations in session. So I have something like following

        http("Navigate to random subcategory")
          ).exec(session => {
        val randId = ("${topicsid.random()}")
        session.set("RandomId", randId)

        http("Enter random subcategory topic")

          .queryParam("track_visit", "true")
          .queryParam("forceLoad", "true")

I’m getting Vector with topicsid and trying to simply put random ID to newly created session variable RandomId in order to use it in next requests to no avail. Next request will be issued like https:///t/${topicsid.random()}.json so it’s not interpreting the variable but using that value as string instead.

Would you please point me in the right direction to find out what am I doing wrong?

Do a println on the value of randId before you exit the block where you set it, to confirm that the syntax you are using to set RandomId is correct

I did and i can see that when i’m doing val randId = ("${topicsid.random()}") hoping that i could put randomly selected value of variable “topicsid” to the variable “randId” for storing it and using in the future calls i’m getting just a string " ${topicsid.random()} " inside “randId”.

So i guess the real question here is “How can i get the value of the variable outside of the session so i will be able to put it’s session value to a separate variable?”, right? Something like “session.get” to introduce the variable to the session before “session.set”?