Hi,
I need use session variable inside jsonpath but it’s giving me type -error. Looks like I need to tell jsonpath this is session variable, though I tried with “session =>” syntax but no luck.
Can someone please help me in this ?. Also , how can I convert my “session variable” to a variable, which can be used directly in jsonpath ?.
Code :
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class RecordedSimulation extends Simulation {
val httpProtocol = http
.baseURL(“http://api.test.local”)
.inferHtmlResources()
.acceptHeader(“application/json, text/javascript, /; q=0.01”)
.acceptEncodingHeader(“gzip, deflate”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.userAgentHeader(“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0”)
val uri1 = “http://api.test.local/api/v1/services”
val count = new java.util.concurrent.atomic.AtomicInteger(1)
var test = "“platform-qa-test-service-1-0-0-test-1"”
val scn = scenario(“Test”)
.exec(session => session.set(“s_count”, count.getAndIncrement))
.exec(session => session.set(“qaservice”, “platform-qa-test-service-1-0-0-test-” + session(“s_count”).as[String]))
.exec(http(“GetService”)
.get(uri1)
.header(“Content-Type”, “application/json”)
.check(status is 200)
.check(jsonPath("$…[?(@.Permalink== " +test+ “)].ID”).saveAs(“loadID”)) // With test variable it’s working
setUp(scn.inject(rampUsers(2) over(20 seconds))).protocols(httpProtocol)
}