In a csv file I've something like this
term
testing
I want to split testing into characters. I want something like this :
.feed(Feeders.search)
.foreach("${term}".toList, "search") {
exec(http("Auto Complete")
.get("${baseUrlHttps}/search/autocomplete")
.queryParam("term", "${search}")
.check(status is 200)
.check(jsonPath("$..products[0].code").optional.saveAs("code"))).pause(MIN_PAUSE, MAX_PAUSE)
}
The above code is not working as I wanted, it's splitting "${term}" into characters though I wanted to convert word "testing" which is in csv in to characters. Is there any workaround for it ?
That's not how autocomplete works. You're not posting chars by chars, you're reposting with one more char. Eg, you'll be posting "test", then "testi" then "testin" and finally "testing" (there's usually a minimum length.
exec { session =>
val term = session("term").as[String]
val parts = for (i <- 3 to term.size) yield term.substring(0, i)
session.set("parts", parts)
}
.foreach("${parts}", "search") {
exec(http("Auto Complete")
.get("${baseUrlHttps}/search/autocomplete")
.queryParam("term", "${search}")
.check(status is 200)
.check(jsonPath("$..products[0].code").optional.saveAs("code"))).pause(MIN_PAUSE, MAX_PAUSE)
}