[英]Gatling - Scala : How to repeat a request until a certain response variable exists in the API response?
Gatling - Scala: How to repeat a request until a certain response variable exists in the API response? Gatling - Scala:如何重复请求,直到 API 响应中存在某个响应变量?
This is the request to find the response time of a cursor pagination API这是求一个cursor分页API的响应时间的请求
.exec(http("APITests:Cursor Pagination")
.get("/testapi")
.queryParam("sortField", "ID")
.queryParam("limit", limitCount)
.queryParam("cursor", "#{CursorID}")
.check(jsonPath("$.nextCursor")).exists
.check(status.is(200))
)
I have to repeat the request execution until .check(jsonPath("$.nextCursor")).exists = False我必须重复请求执行直到.check(jsonPath("$.nextCursor")).exists = False
Please provide suggestions and help请提供建议和帮助
I tried below ending with error:我在下面尝试以错误结尾:
doWhile(session => session(".check(jsonPath(\"$.nextCursor\").exists").as[Boolean]) {
exec(http("APITests:Cursor Pagination")
.get("/testapi")
.queryParam("sortField", "ID")
.queryParam("limit", limitCount)
.queryParam("cursor", "#{CursorID}")
.check(status.is(200))
.check(jsonPath("$.nextCursor").exists
))
}
But I end up with error: jsonPath($.nextCursor).find.exists, found nothing但我最终遇到错误: jsonPath($.nextCursor).find.exists, found nothing
Use contains
, but you have to save nextCursor
into Session
使用
contains
,但你必须将nextCursor
保存到Session
doWhile(session => !session.contains("nextCursor")) {
exec(http("...")
.get("/")
.check(jsonPath("$.nextCursor").saveAs("nextCursor"))
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.