![](/img/trans.png)
[英]How to pass and get attributes in Gatling session from and to "exec" blocks
[英]How to pass a session variable from one object to another in Gatling?
我在ObjectA中提取會話變量並希望將其傳遞給ObjectB,實現這一目標的最佳方法是什么?
object ObjectA {
val foo = exec(jsfPost("Request1", "/something.xhtml")
.formParam("SUBMIT", "1")
.check(regex("""Count:([^:]*),""").saveAs("Count"))
)
.pause(1)
.exec { session =>
val Count = session("Count").as[String].toInt
val GroupName = SomeCustomFunc(Count)
}
.exec(ObjectB.bar)
}
object ObjectB{
val bar = group(GroupName){
myChain
}
}
很確定看到答案后我會感到愚蠢,但到目前為止還沒有成功。
答:正如Stephane建議通過會議工作正常:
object ObjectA {
val foo = exec(jsfPost("Request1", "/something.xhtml")
.formParam("SUBMIT", "1")
.check(regex("""Count:([^:]*),""").saveAs("Count"))
)
.pause(1)
.exec(session => session.set("GroupName", SomeCustomFunc(session("Count").as[String].toInt)))
.exec(ObjectB.bar)
}
object ObjectB{
val bar = group("${GroupName}"){
myChain
}
}
您必須在exec(函數)中的用戶會話中存儲GroupName,以便以后可以獲取它(Gatling EL或函數)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.