Hi
Then, in order to add a cookie to the CookieJar so it’s automatically sent, there’s a addCookies action: https://github.com/excilys/gatling/wiki/Gatling-2#wiki-http-misc
The thing is it’s quite complex to use in 2M3a, so it has been refactored in master/upcoming M4:
https://github.com/excilys/gatling/blob/master/gatling-app/src/test/scala/io/gatling/app/test/CompileTest.scala#L192
Indeed, I guess that I could do a
.exec(addCookie(“session-id”, “${test}”))
Is there a quick way to get some kind of nightly build?
Thanks
Yep, snapshots are on Sonatype:
https://github.com/excilys/gatling/wiki/Continuous-Integration
Regarding addCookie, see method signature here:
https://github.com/excilys/gatling/blob/master/gatling-http/src/main/scala/io/gatling/http/Predef.scala#L37
I got the snapshot from https://oss.sonatype.org/content/repositories/snapshots/io/gatling/gatling-bundle/2.0.0-SNAPSHOT/
I added 2 libs logback- classic and core
I had to comment out
// import io.gatling.http.Headers.Names._
// import io.gatling.http.Headers.Values._
// import bootstrap._
// import assertions._
but I still have an error:
GATLING_HOME is set to “C:\Programs\Gatling”
18:20:50.084 [ERROR] i.g.a.ZincCompiler$ - C:\Programs\Gatling\user-files\simulations\se\box\browse.scala:139: not found: value atOnce
18:20:50.087 [ERROR] i.g.a.ZincCompiler$ - setUp(scn.inject(atOnce(1 users),
18:20:50.088 [ERROR] i.g.a.ZincCompiler$ - ^
18:20:50.103 [ERROR] i.g.a.ZincCompiler$ - one error found
Compilation failed
Yep
OK getting the right bundle.
Still have to:
- Add logback- classic and core from previous Gatling lib.
- Remove the examples (compilation errors)
Then it worked !
.exec(http(“request_Login”)
.post("/access")
.queryParam(“action”, “login”)
.body(StringBody("""{“login”:“adm”,“password”:“adm*”}"""))
.headers(headers_json)
)
.pause(1)
.exec( session => {
import io.gatling.http.cookie._
import java.net.URI
val ck = session(“gatling.http.cookies”).as[CookieJar].get(URI.create(“http://bdist/access”)).find(
_.getName == “session-id”
)
session.set(“test”, ck.getOrElse(null).getValue)
})
.exec(
addCookie(“session-id”, “${test}”) // Default to path=/
)
But I also found out that I don’t need this anymore !?
With 2.0.0M3 the path was “/access” (were I got the cookie)
With the Snapshot, the path is “/”
Note that it is fine for me.
Thanks a lot.
Bruno