[英]Gatling - Scala : How to repeat a request until a certain response variable exists in the API response?
Gatling - Scala:如何重復請求,直到 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))
)
我必須重復請求執行直到.check(jsonPath("$.nextCursor")).exists = False
請提供建議和幫助
我在下面嘗試以錯誤結尾:
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
))
}
但我最終遇到錯誤: jsonPath($.nextCursor).find.exists, found nothing
使用contains
,但你必須將nextCursor
保存到Session
doWhile(session => !session.contains("nextCursor")) {
exec(http("...")
.get("/")
.check(jsonPath("$.nextCursor").saveAs("nextCursor"))
)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.