String interpolation from the Session not working with Gatling 2.0.0

Hi I have following code:
.exec(http("/homepage")
.get("/en")
.check(headerRegex(“Set-Cookie”, “"“token=(.*?);”"").saveAs(“token")))
.exec( session => {
println(“${token}")
session })
I don’t see ${token} correctly interpreted, I get literal String ${token} printed. I need to use this syntax since I am passing a POST request parameters using ELFileBody. Is this a Gatling bug?

Thanks

Hi Mayumi,

Gatling’s EL doesn’t work everywhere. More specifically, it works where the parameter is an Expression[T], which is not the case of println().
There won’t be any problem to use the token you saved inside an ELFileBody :wink:

If you want to debug your simulation using println(), you’ll need to use the Session API to fetch the token from the session and print it :

exec(session => {
println(session(“token”).as[String])
session
})

Cheers,

Pierre

I think we have this properly explained in the documentation: http://gatling.io/docs/2.0.0-RC2/session/expression_el.html

Is there any ways to verify the request parameters are correctly set? I am getting “Bad Request (400 error)” exception from the receiver of this request. In other words I want to print the entire request body, header, etc before dispatching the POST request. This is to verify that ${token} in the text file is correctly interpolated and my request information is correctly set.

Thanks,

Mayumi

The simplest way to do it is to modify the logback.xml file and uncomment :

<!-- —> Cheers, Pierre

This way, all Gatling debug info get printed in the console, showing the sent requests and their bodies.

The most convenient way for now is to use something like Charles Proxy. Don’t forget to declare it in Gatling’s HTTP protocol proxy config.

Sorry, I should have said “most complete”. With debug log, you might miss some information.

Thanks for the information!