scalaunix-timestampgatling

How to pass epoch timestamp in each requests of Gatling script dynamically


I have to pass current epoch timestamp in below "request_1" and "request_2" dynamically. How can I achieve this. Below are just few requests given, actually there are many requests in scripts.

Here all requests should have current timestamp only. So each requests will have different different timestamp.

Is there any function so that I can replace all timestamp directly without replacing one by one.

  val Transaction_Name_1 = group("Transaction_Name_1")
  {
      exec(http("request_1")
        .get("/abc/details1?_=1590748529401"))
      .pause(5)
      .exec(http("request_2")
        .get("/abc/details1?_=1590748535534"))
  }

Solution

  • In Gatling 3.4.0 we introduced a new Gatling EL feature so you can be able to write:

    (edit: update for the new syntax introduced in Gatling 3.7)

    val Transaction_Name_1 = group("Transaction_Name_1") {
      exec(http("request_1")
        .get("/abc/details1?_=#{currentTimeMillis()}")
      .pause(5)
      .exec(http("request_2")
        .get("/abc/details1?_=#{currentTimeMillis()}"))
    }