在测试过程中提取cookie值字符串



我的测试运行良好,但是现在我需要一次进行多个会话。我尝试使用headerRegex("Set-Cookie", "HOME_SESSID=(.*)").saveAs("homeSessid")获取cookie值,但是当我打印出它的返回时, com.excilys.ebi.gatling.http.check.HttpMultipleCheckBuilder@6075598

的值

我不知道这是从哪里来的。我的问题是:发生了什么?

谢谢。

编辑:忘了提及其返回的值不是会话ID,无论我在cookie名称中使用什么,我都会获得相同的值。

编辑(解决方案):

1)在第一个.exec中: .check( headerRegex("Set-Cookie", """HOME_SESSID=(.*dll/(d+))""").saveAs("homeSessid") )

2)然后在以后的http请求中检索homeSessid,例如: .post( session=>{session}.getAttribute("homeSessid").toString + "/some/relative/url" )

1)在第一个.exec中:

.check( headerRegex("Set-Cookie", """HOME_SESSID=(.*dll/(d+))""").saveAs("homeSessid") )

2)然后在以后的http请求中检索homesessid,例如:
.post( session=>{session}.getAttribute("homeSessid").toString + "/some/relative/url" )

请正确阅读支票文档。检查将数据保存到会话中,因此您必须阅读。在这里,您只是想打印提取器。

例如,执行检查后,您可以添加一个exec(函数),例如:

.exec(session => {
  println(session("homeSessid").as[String]) // Gatling 2 API
  session
})

最新更新