Gatling - Getting Scenario Iteration Number

Hi,

I have group of request in a scenario. My condition is to execute each request based on condition/iteration number. How can i get iteration number from session attributes?

Below is the same session attributes on runtime where attribute ‘4769a827-b3ce-4cf6-971f-6e88b8dd8e54’ says the iteration number for the specific user

Session Attributes —>Map(gatling.http.cache.dns → io.gatling.http.cache.DnsCacheSupport$$anon$1@61d80be8, gatling.http.ssl.sslContexts → SslContexts(io.netty.handler.ssl.ReferenceCountedOpenSslClientContext@6ba0fa0f,None), 4769a827-b3ce-4cf6-971f-6e88b8dd8e54 → 5)

Thanks for your suggestion

You can get the iteration number using “counterName” parameter of any loop.

Please refer https://gatling.io/docs/current/general/scenario/

Hi,

Thanks for your feedback,

I am not using repeat keyword here. I am using injection profile with maxDuration. any suggestion in this case?

Thanks

Got it! in scenario definition, previously i used forever. Now changed to during(MaxDuration, counterName).

Let me check this details and get back.

You can use this parameter within any type of loop. If you are using during then you can use the counterName within this as well.
Or you can share the code so that I can help you.

Thanks raman for your time. now i am getting the iteration number as expected after defining countername.