簡體   English   中英

加特林-在測試期間提取cookie值字符串

[英]gatling - extract cookie value string during test

我的測試運行正常,但現在我需要一次運行多個會話。 我嘗試使用headerRegex("Set-Cookie", "HOME_SESSID=(.*)").saveAs("homeSessid")獲取cookie值headerRegex("Set-Cookie", "HOME_SESSID=(.*)").saveAs("homeSessid")但是當我打印出它的返回值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" )

請正確閱讀檢查文檔 檢查將數據保存到會話中,因此您必須在其中讀取。 在這里,您只是嘗試打印提取程序。

例如,執行檢查后,可以添加exec(function) ,例如:

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

1)在第一個.exec文件中:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM