How to get Session values into scala variables

Hey, I’m coming primarily from a Jmeter background and on several of my projects I need to manipulate regexed values which are easily accessed and modified outside the flow with a vars.get and vars.set. I’m new at Gatling and Scala and I’m having trouble getting that kind of behavior to work in Gatling. My first attempt to put a regexed value into a scala variable failed:


val test_str = session("regex_str").as[String]


This is what I thought would work based on the Session API documentation. There wasn’t a concrete example to follow so I assumed it would work this way. Any insight would be helpful. Thanks!

Could you provide a bit more description of what you’re trying to do? Are you actually trying to store the regex itself, or are you trying to store the results of applying a regex to a response? Assuming you want to store the results, you should check out in particular the regex function.