Reputation: 163
I'm trying to check if the responses of my regex are in my JSON. For that I stored the regex response into a variable metas. Now i need to browse into this variable to compare with all the values of metas and I don't figure out how to write this. \"${metas(\"${nbr_metas}\")}\" doesn't seem to be working.
here how i am doing:
val scn_get_content = scenario("Test")
.exec(http("get metas")
.get(url+"/"+json_file)
.check(status.is(200))
.check(regex("\"([^\"]*)\":").findAll.saveAs("metas")))
.pause(1)
.repeat("${metas.size()}", "nbr_metas") {
exec(http("Get JSON")
.get(url_json)
.headers(headers_1)
.check(status.is(200))
.check(responseTimeInMillis.lessThan(1000))
.check(jsonPath("$.\"${metas(\"${nbr_metas}\")}\".findAll").exists))
Thanks
Upvotes: 0
Views: 534
Reputation: 163
I have yet encountered the same problem, and finally found the solution.
.foreach("${url}", "session_url", "counter")(
exec(http("url")
.get("${url(counter)}")
.headers(headers_1)
.check(status.is(200))
))
in my example url is a session attribute and counter is the counter...
hope it'll help some people!
Upvotes: 1
Reputation: 7038
For checks on JSON documents, you'd better use JsonPath checks.
Upvotes: 0