我正在尝试执行doWhile,但遇到了以下编译错误:
在trait循环中缺少方法doWhile的参数列表只有当需要函数类型时,未应用的方法才会转换为函数。您可以通过写入
doWhile _
或doWhile(_,_)(_)
而不是doWhile
来显式地进行此转换。
这是我的代码:
builder
.doWhile("${scrollId.exists()}") {
exec(http(s"$title")
.post(endpoint)
.headers(headers)
.body(ElFileBody(requestBodyFilePath))
.check(jsonPath("$.scrollId").saveAs("scrollId"))
.check(status.is(200)))
.pause(1)
//save value from response
.exec(session => {
.doIf(session("scrollId").asOption[String].isEmpty)
val scrollId = session("scrollId").asOption[String].get
session.set("scrollId", scrollId)
})
}
}
谢谢!
doWhile
的正确语法是doWhile(condition) { chain }
,例如:
builder
.doWhile("${scrollId.exists()}") {
exec(http(s"$title")
.post(endpoint)
.headers(headers)
.body(ElFileBody(requestBodyFilePath))
.check(jsonPath("$.scrollId").saveAs("scrollId"))
.check(status.is(200)))
.pause(1)
//save value from response
.exec(session => {
val scrollId = session("scrollId").asOption[String].get
session.set("scrollId", scrollId)
})
}