在执行请求时在 Gatling 中遇到 doWhile 问题

Getting a problem with doWhile in Gatling while doing requests

我正在尝试执行 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 _ or doWhile(_,_)(_) instead of 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)
          })
   }