I'm trying to use Gatling to test my API but I've got a problem. I'm testing for now the login/logout. At the login, the user got a token, that is used for logout.
When I use the recorder, it keep a fix token, and of course, it doesn't work when I run the test. But I don't find in the doc or google how I can get dynamically the token.
Does anyone know ?
Thanks !
EDIT:
after recording here what I got
val headers_13 = Map(
"Accept" -> """*/*""",
"Origin" -> """http://site.com""",
"token" -> """token"""
)
val scn = scenario("Scenario Name")
.exec(http("request_1")
.post("http://site.com/login")
.headers(headers_1)
.param("""player[email]""", """[email protected]""")
.param("""player[password]""", """password""")
)
.pause(757 milliseconds)
…
.exec(http("request_13")
.get("http://site.com/logout")
.headers(headers_13)
)
.pause(202 milliseconds)
I try to put the two pieces of code after .post("http://site.com/login") and .get("http://site.com/logout") but that didn't works
Where is your token? Is it a HTTP header? Generally speaking, the way to save data from responses in order to reuse it for further requests is the Check API.
.check(header("tokenName").saveAs("token")
...
.header("tokenName", "${token}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With