Looks like it is not picking values from CSV file. How to get the values from CSV file and manipulate before passing them to post request body. I need to pick the first 4 values from each Session_ID string(For Example: 362, 75, 1, 2)
Thanks for the reply. Yes in my csv file first row of session_ID values column is Session_ID. but doesn’t work. CSV feeder works in the post request body. But as I have experienced it doesn’t work if I need to pick a value from CSV feeder and save it to the variable for example.
What you’re trying to do is not going to work, at least not the way you are doing it. You are mixing build-time code with run time code.
The value of scn1 is an object that describes a scenario. The scenario has not started running yet. So your code that is trying to manipulate the session is executing outside of the context of a running virtual user, and has no access to a session.
In order to do what you want, you have to embed the logic inside of an .exec( Session => Session ) call, like so:
val scn1 =
scenario(“Get_Assign_SelfSCH_Websocket1”)
.feed(SessionIDFeeder)
.exec( session => {
val strSocket_URL = session(“Session_ID”).as[String]
println(strSocket_URL)
val strSocketSplit = strSocket_URL.split(separator)
println(strSocketSplit(0))
session
})
Notice how I did not re-use global variables inside the exec block? This is because this code will be executed by every virtual user, which means if you try to manipulate global variables, they may stomp all over each other.