Invoking a method/function during a simulation run


I have to load test a web page that has about 10 ajax calls. Some ajax calls return raw input for other ajax calls. I was able to successfully transform data of some ajax calls and use it in the same simulation later.

But for one of them I am somewhat stumped.

Here is the scenario

val AjaxCall = .exec(..) . get(...) . check(jsonPath(...).findAll . saveAs("myName")

myName variable returns a Vector, since jsonPath has multiple rows.


def MyProgram (input:Vector) : String ={
do stuff
return myString

if I do the following, then it does not work

val NextAjaxCall = .exec(…) . get(… + MyProgram(“myName”.as[Vector]))


I am sure there is an easy way to do it. If someone can point me in the right direction.


My best guess is that “… + MyProgram(“myName”.as[Vector])” isn’t a function, so it’s only computed when the simulation is loaded.

The problem I had was .as[Vector] as an argument in the previous post was not compiling. I used transform and rewrote the function in it. it worked.

Still I would love to know how I can call method at simulation run time without using .exec(session =>…)

NVM, I found out that I have to do exec{session => …} to get value from another method during simulation runs.