尝试从字符串中捕获jsession id
jsessionid=an121kj533n232j53531314353.tomcat_17221212_1101
Gatling 2.2.3
中
.check(regex(""jsessionid=\"(.*?).tomcat"").saveAs("jsessid"))
编译期间出现跟随错误
`[ERROR] i.g.c.ZincCompiler$ - C:\Users\xxx\Desktop\gatling-2.2.3\user-files\simulations\RecordedSimulation.scala:31: value check is not a member of io.gatling.http.request.builder.Http possible cause: maybe a semicolon is missing before 'value check'?
15:09:05.780 [ERROR] i.g.c.ZincCompiler$ - .check(regex("\"jsessionid=\"(.*?).tomcat").saveAs("jsessid"))`
添加了代码以更好地呈现问题。我是Scala / Gatling的新手,非常感谢任何帮助。实际代码
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("https://XXXXX.net:9191")
.inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0")
val headers_2 = Map("Accept" -> "image/png,image/*;q=0.8,*/*;q=0.5")
val uri1 = "https://login-qa.XXXX.net:443/minderagent/SmMakeCookie.ccc"
val uri2 = "https://login-qa.XXXX.net:443/minderagent"
val uri3 = "https://XXXXX.svr.us.XXXXX.net:9191/web"
val scn = scenario("RecordedSimulation")
// Launch
.exec(http("request_0")
.get("/web/")
.check(regex("\"jsessionid=\"(.*?).tomcat").saveAs("jsessid")))
.pause(24)
// Login
.exec(http("request_1")
.post(uri2 + "/SSOlogin.fcc")
.formParam("SMENC", "ISO-8859-1")
.formParam("SMLOCALE", "US-EN")
.formParam("location", "")
.formParam("target", "HTTPS://XXXXX.svr.us.XXXXX.net:9191/web/")
.formParam("smauthreason", "0")
.formParam("smagentname", "XXXX+xirJXXJhSPoyD4OiZyLt1C0KEntKHOu0n3c9AIjJ0oMQ7vtB2z2PtaGfRQrMCNbVlFycMzQmdjGuQMXXXXXhnprOFAn8")
.formParam("postpreservationdata", "")
.formParam("USER", "XXXXX")
.formParam("PASSWORD", "XXXXX")
.resources(http("request_2")
.get("/web/common/images/cme.jpg;jsessionid=${jsessid}.tomcat_1232323_11002")
.headers(headers_2),
http("request_3")
.get("/cmeweb/common/images/Title.jpg;jsessionid=${jsessid}.tomcat_1232323_11002")
.headers(headers_2),
http("request_4")
.get("/web/common/images/logo_chase.gif;jsessionid=${jsessid}.tomcat_1232323_11002")
.headers(headers_2),
http("request_5")
.get(uri1 + "?SMSESSION=QUERY&PERSIST=0&TARGET=$SM$https%3a%2f%2fvsin8u4784%2esvr%2eus%2eXXXXX%2enet%3a9191%2ffavicon%2eico"),
http("request_6")
.get(uri2 + "/SSOlogin.fcc?TYPE=33554433&REALMOID=06-000a5275-6315-16fb-8d7a-895aa9454077&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=$SM$UKnA%2bxirJXXJhSPoyD4OiZyLt1C0KEntKHOu0n3c9AIjJ0oMQ7vtB2z2PtaGfRQrMCNbVlFycMzQmdjGuQMhnpYx0srOFAn8&TARGET=$SM$HTTPS%3a%2f%2fvsin8u4784%2esvr%2eus%2eXXXXX%2enet%3a9191%2ffavicon%2eico")))
.pause(12)
// Click Batch
.exec(http("request_7")
.get("/web/batchtracking!view.action;jsessionid=${jsessid}.tomcat_1232323_11002"))
.pause(13)
// Search Batch
.exec(http("request_8")
.post("/cmeweb/batchtracking!doSearch.action")
.formParam("startDate", "07/22/2016")
.formParam("endDate", "07/22/2016")
.formParam("cmeUser", "")
.formParam("sortColumnAlias", "Default"))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)}
当我在启动标记下移动.check函数,在get之后移动rite时,没有得到上述错误 但需要帮助在jessionid'jsessionid = an121kj533n232j53531314353 .tomcat_17221212_1101'
中捕捉价值