isanma
isanma

Reputation: 175

Getting a problem with doWhile in Gatling while doing requests

I am trying to execute a doWhile but I am getting this compilation error:

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.

This is my code:

    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)
    })
  }
}

Thank you!

Upvotes: 2

Views: 1469

Answers (1)

Stéphane LANDELLE
Stéphane LANDELLE

Reputation: 6623

The correct syntax for doWhile is doWhile(condition) { chain }, eg:

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)
          })
   }

Upvotes: 3

Related Questions