我正在尝试执行 doWhile 但收到此编译错误:
missing argument list for method doWhile in trait Loops Unapplied methods are only converted to functions when a function type is expected. You can make this conversion explicit by writing
doWhile _
ordoWhile(_,_)(_)
instead ofdoWhile
.
这是我的代码:
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)
})
}
关于java - 在加特林中执行请求时遇到 doWhile 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68438008/