I simulate selecting a product in my application.
My get method return a json with severals product object.
I want to select id, number and version in random way for the moment I select them with an Int value = 1 which I provide every time.
.check(status.in(200 to 210))
.check(jsonPath("$[1][‘id’]").saveAs(“id”))
.check(jsonPath("$[1][‘number’]").saveAs(“number”))
.check(jsonPath("$[1][‘version’]").saveAs(“version”)))
First, you have to use ofMap to tell Gatling you want to extract JSON objects (Java Maps) to directly capture nodes, not fields/leaves.
Then, you have to use findRandom() to tell Gatling you want to extract one random result amongst all the matches.