简体   繁体   中英

Get token id from Login request in Gatling

I am using Gatling for performance testing, so I want know that how we extract token id from the login request here is code

val scn = scenario("Navigation")
    .exec(http("request_6")
        .post("/WEBAUTO03/aurora/login/security_check")
        .headers(headers_6)
        .formParam("j_username", "TONY")
        .formParam("j_password", "1234")
        .formParam("doLogin", "")

Above request provide token and I need apply the token in following request

val headers_9 = Map(
    "Content-type" -> "text/plain",
    "Origin" -> "https://resource.com",
    "X-XSRF-TOKEN" -> ""4c81ed9c-e509-4830-b724-62e489c918e2"")       -----here i need to replace token 


        .exec(http("request_9")
        .post("/WEBAUTO03/aurora/JSON-RPC")
        .headers(headers_9)
        .body(RawFileBody("webview/navigation/0009_request.txt")))

anyone have any idea

Without seeing the response from the "above request" we cannot suggest the exact steps, approximate would be something like:

http("request_6")
.post("/WEBAUTO03/aurora/login/security_check")
.check(css("input[name='csrf_token']", "value").saveAs("Correlation1"))

val headers_9 = Map(
"Content-type" -> "text/plain",
"Origin" -> "https://resource.com",
"X-CSRF-Token" -> "${Correlation1}")

More information:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM