Gatling: How to change saved integer value
I save number of getting elements as integer value.
val getElements = exec(http("1. get_elements")
.get("/apis/;version=0/elements/items?")
.check(jsonPath("$.totalElements").ofType[Int].saveAs("total_elements"))
.check(status.is(200))
.headers(headers_common))
But I can not modify this value in another function, for example:
.repeat("${total_elements}" / 100){
.....
}
From documentation:
Warning
This Expression Language only works on String values being passed to Gatling DSL methods. Such Strings are parsed only once, when the Gatling simulation is being instantiated.
For example queryParam("latitude", session => "${latitude}") wouldn’t work because the parameter is not a String, but a function that returns a String.
Also, queryParam("latitude", "${latitude}".toInt) wouldn’t because the toInt would happen before passing the parameter to the queryParam method.
The solution here would be to pass a function:
So you have to pass a function where you would use the Session API. In your case:
repeat(session => session("total_elements").as[Int] / 100) { ... }