Translating a ChainBuilder

Ok, so odd question and situation.

I have a function that returns a ChainBuilder and a String. I then assign each of these to a variable. Then when I try to display them on the screen, the script compiles and it appears they are in the correct data type, but the string comes out as a ChainBuilder.

Does anyone know why this might happen, and how to fix it so that the String is displayed as the String I’m expecting?

Thanks for all of your help.


Please post your sample code and the output!

Thanks for the reply,

Here is the sample code for the method:

object BasicLogin {

def login ( hostparam:String, controlparam:String, usernameparam:String, passwordparam:String) : (ChainBuilder, String) = {

val user = usernameparam

val password = passwordparam

val host = hostparam
val controlid = controlparam
val logintype = "user"

val jsonrequest = “”"{“logintype”:"""" + logintype + “”"",
"controlid":"""" + controlid + “”"",
"user":"""" + user + “”"",
"password":"""" + password + “”"",
"host":"""" + host + “”""

val loginChain = exec(http(“Login”)

val accessToken: String = exec(session => {
val sessionid = session(“currentSession”).as[String]
println("token: " + sessionid)
session })

return (loginChain, accessToken)

Here is my code calling the method for login:

val host = "IPaddress"
val controlid = "IDcontroller"
val username = "JDoe"
val password = "TerriblePassword"

val result = BasicLogin.login(host, controlid, username, password)
val basiclogin:ChainBuilder = result._1
val currentSession:String = result._2

println("Session: " + currentSession)
println("Login: " + basiclogin)

And here is what I get in response:

Session: ChainBuilder(List(io.gatling.core.action.builder.SessionHookBuilder@6f70f32f))
Login: ChainBuilder(List(io.gatling.http.action.sync.HttpRequestActionBuilder@3dd69f5a))

I do want to note that the println("token " + sessionID) does not get returned to the screen. Any idea what it is I am missing here?

Thanks for the help,


I’m curious why would you write something like this to see the value of the session? Right now it’s printing the string representation of the action builder object rather than the actual value of your token.

You can very easily enable debug logging to watch session parameters as opposed to passing this variable around and printing them all over the place. Go to resources->logback.xml and uncomment the debug log to watch your session. I hope you are only doing this locally or for testing. Don’t enable debug when running actual test.

If you still want to use the code as is, you should change your login method return statement from accessToken to the actual session value that you assign to val from session.

Good luck.


Thanks for the reply ESJ.

You are correct, I am only doing this for testing. The session will not be displayed once I have the test finished in coding. I had it display just because I wanted to see if the value of accessToken is being passed to currentSession. This is important because then in future functionality tests, I may need to pass the session token using currentSession as a parameter in a method. My problem is that I have not been successful in getting the value of accessToken to be passed to currentSession.

As for the return statement, are you suggesting I return sessionid instead of accessToken? If this is the case, I have attempted to do something similar to this by trying to return currentSession from the loginChain val, using several different methods (i.e. currentSession, $currentSession, “${currentSession}”, ${currentSession}) which none of those worked. I will try returning sessionid as I think you are suggesting, but if I misunderstood, please let me know. I will report back with how it went.

Thanks for your help!


So the response I got from returning sessionid is the same as with all of the currentSession attempts. “value not found”.

Any ideas as to what I’m missing?


Any ideas?