implement code in a Gatling script

I have an issue where the client generates an id (no http traffic).

I know that gatling won’t execute javascript, but is it possible to programmatically (looking at that javascript code that generates the id) to implant this kind of logic into the script? i.e. using plain java or scala?


Actually to be more specific. I am talking about generating epoch og into the gatling script.
Any idea on how to do that “on the fly” within a simulation?


Looking at some posts at this forum I guess it could be something like this:




Map(“timestamp” → System.currentTimeMillis().toString())



.post(uri2 + “?ajax_id=GET_ARTICLE_DETAILS&ajax_applid=UI5_RETAIL_ORDER_LABEL&field_id=00055&ajax_value=${art}”)


.formParam("""{“WERKS”:"${storenumber}",“NAME1”:"${storename}",“LIST_ID”:"${timestamp}",“TOTAL_LISTS”:"${total_lists}",“DEVICE_ID”:“win8ff38”,“HEADER_TEXT”:"",“HASH_BASED_MESSAGE_AUTHENTICAT”:“42”,“ID”:“1012371-77-739”,“REVISION”:0,“LABEL_TYPE_LOCKED”:false,“LABEL_TYPE”:“0”}||{}||{}||{}||[{“ID”:0,“NAME”:“Standard”},{“ID”:23,“NAME”:“Etikett (11 x 2) Butikkringen”},{“ID”:24,“NAME”:“Liten etikett (5 x 3) Butikkringen”},{“ID”:41,“NAME”:“Prislapp (36 x 17)”},{“ID”:51,“NAME”:“IS prislapp 48 x 28”},{“ID”:61,“NAME”:“G etikett 72 x 39”},{“ID”:301,“NAME”:“Etikett 11 x 2 Plenty”},{“ID”:321,“NAME”:“Neste Stopp prislapp u.pris”},{“ID”:325,“NAME”:“Prislapp uten pris (11 x 3)”},{“ID”:344,“NAME”:“Prislapp (rull 25 x 60)”},{“ID”:351,“NAME”:“ÖoB medium”}]""", “”)



This is however not working, as in I get the error:

If you’re trying to accomplish getting the current date time, why can’t you do just do new Date().getTime, or with Joda DateTime:

Then you can save this timestamp whenever you want into the session:

.exec(_.set(“timestamp”, new Date().getTime)) // sets “timestamp” to millis since epoch.

Thank you Andrew,
But the Date (in new Date turns red) what import do I need to do to make this work?


Found it,

The classic java.util.Date:

If you can set it up, it’s extremely useful to have your IDE resolve imports for you.

I sure did set it up, and if found it for me.