hi..
I need the size of session variable...
I am trying like this
session => {
val size = "${CallbackHandlerPathList.size()}"
println("sizeoflist:"+ size)
session
}
but it is not getting me anything.. simply print the val as string as it is
That won’t work. EL (http://gatling.io/docs/2.2.3/session/expression_el.html) can be passed to Gatling DSL functions but not used in your own functions.
Get the value using session(“CallbackHandlerPathList”) and then programmatically get the size of the resulting val.
Hi Barry.
Actually CallbackHandlerPathList contain List I need that size of List.
Hi Barry,
Yes that helped but stuck in another problem:
.foreach("${CallbackHandlerPathList}", "handler") {
exec(session => {
//println("ids:"+ids)
//println("WidgetIDS:"+ session("WidgetIDS(counter)"))
var attribute = session("WidgetIDS").as[List[String]].distinct
println("WidgetIDS:"+attribute(counter))
var Guid = session("Guid").as[List[String]].distinct
println("Guid:"+Guid(counter))
var Titles = session("Titles").as[List[String]].distinct
println("Titles:"+Titles(counter))
val handle = session("handler").as[String]
println("Handler:"+session("handler").as[String])
http("widgetcall")
.post("https://www.testciq.com"+handle)// I am not able to use the session attribute extracted.. in a post call giving error **Type mismatch, expected session.Expression[String], Actual Validation[String]**
Kindly suggest what am I doing wrong
Hi... This is the updated script which compiles successfully but still the http call inside the loop is not executing
.exec(http("Dashboard123")
.get(uri10 + "/CIQDotNet/my/dashboard.aspx").headers(headers_0)
.disableFollowRedirect
//.check(regex("""CallbackHandlerPath":"(.*).axd" """).saveAs("CallbackHandlerPathList"))
//.check(regex(""""CallbackHandlerPath":"([a-zA-Z0-9._/^,]*)","""").ofType[(String, String)].findAll.saveAs("CallbackHandlerPathList"))
.check(regex(""""CallbackHandlerPath":"([a-zA-Z0-9._/]*)","""").findAll.saveAs("CallbackHandlerPathList"))
.check(regex(""""WidgetId":([0-9]*\d{5,11}),"""").findAll.saveAs("WidgetIDS"))
.check(regex(""""TemplateId":([0-9]*),"""").saveAs("wpTemplateId"))
.check(regex(""""Title":"([a-z A-Z]*)","""").findAll.saveAs("Titles"))
.check(regex(""""Guid":"([a-zA-Z0-9-]*)","""").findAll.saveAs("Guid"))
)
.exec {
foreach("${CallbackHandlerPathList}", "handler") {
exec(session => {
//println("ids:"+ids)
//println("WidgetIDS:"+ session("WidgetIDS(counter)"))
var attribute = session("WidgetIDS").as[List[String]].distinct
var wpTemplateId = attribute(counter)
println("WidgetIDS:" + attribute(counter))
var Guid = session("Guid").as[List[String]].distinct
var G = Guid(counter)
println("Guid:" + Guid(counter))
var Titles = session("Titles").as[List[String]].distinct
var Title = Titles(counter)
println("Titles:" + Titles(counter))
val handle = session("handler").as[String]
// println("Handler:"+session("handler").as[Expression[String]])
var wpTemplate = session("wpTemplateId").as[String]
println("WidegtCallStarted")
http("widgetcall")
.post("https://www.testciq.com" + handle)
.headers(headers_53)
.formParam("r", "1485376346504")
.formParam("ptype", "13")
.formParam("wpTemplateId", wpTemplate)
.formParam("wState", "{}")
.formParam("wid", wpTemplateId)
.formParam("widgetId", wpTemplateId)
.formParam("wTitle", Title)
.formParam("g", G)
println("WidegtCallEnd")
//val size = "${CallbackHandlerPathList.size()}"
// println("sizeoflist:"+ size)
//println("${CallbackHandlerPathList.size()}")
// val playerId = playerMap("playerId")
counter += 1
println()
session
})
}
}
Getting and error upon execution which is [ERROR] [02/22/2017 18:13:32.932] [GatlingSystem-akka.actor.default-dispatcher-13] [akka://GatlingSystem/user/sessionHook-2] 2
java.lang.IndexOutOfBoundsException: 2
at scala.collection.LinearSeqOptimized$class.apply(LinearSeqOptimized.scala:65)
Kindly suggest something to get this thing work