Hello
I have a web site that set a cookie with a path “/access”. But I would like this cookie to be used on path “/”.
I tried this code, to read the cookie’s value but it doesn’t work. I have an exception.
.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(“//bdist”)).find(
_.getName == “session-id”
)
session.set(“test”, ck.getOrElse(null).getValue)
})
HTTP response:
status=
202 Accepted
headers=
content-type: [application/json]
transfer-encoding: [chunked]
date: [Tue, 29 Oct 2013 15:37:27 GMT]
set-cookie: [session-id=a72e12d3-847c-481d-942d-6928c3667c18; HttpOnly]
<<<<<<<<<<<<<<<<<<<<<<<<<
[ERROR] [10/29/2013 15:43:18.885] [GatlingSystem-akka.actor.default-dispatcher-13] [akka://GatlingSystem/user/$i] null
java.lang.NullPointerException
at se.box.browse$$anonfun$1.apply(browse.scala:113)
at se.box.browse$$anonfun$1.apply(browse.scala:106)
at io.gatling.core.action.SessionHook.executeOrFail(SessionHook.scala:35)
at io.gatling.core.action.Failable$class.execute(Actions.scala:82)
at io.gatling.core.action.SessionHook.execute(SessionHook.scala:28)
at io.gatling.core.action.Action$$anonfun$receive$1.applyOrElse(Actions.scala:42)
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:166)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
at akka.actor.ActorCell.invoke(ActorCell.scala:386)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
at akka.dispatch.Mailbox.run(Mailbox.scala:212)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
15:43:18.926 [ERROR] i.g.c.a.b.SessionHookBuilder$$anonfun$build$1$$anon$1 - Action $anonfun$build$1$$anon$1 crashed, forwarding user to next one
java.lang.NullPointerException: null
at se.box.browse$$anonfun$1.apply(browse.scala:113) ~[na:na]
at se.box.browse$$anonfun$1.apply(browse.scala:106) ~[na:na]
at io.gatling.core.action.SessionHook.executeOrFail(SessionHook.scala:35) ~[gatling-core-2.0.0-M3a.jar:na]
at io.gatling.core.action.Failable$class.execute(Actions.scala:82) ~[gatling-core-2.0.0-M3a.jar:na]
at io.gatling.core.action.SessionHook.execute(SessionHook.scala:28) ~[gatling-core-2.0.0-M3a.jar:na]
at io.gatling.core.action.Action$$anonfun$receive$1.applyOrElse(Actions.scala:42) ~[gatling-core-2.0.0-M3a.jar:na]
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:166) ~[scala-library-2.10.2.jar:na]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425) ~[akka-actor_2.10-2.1.4.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:386) ~[akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230) ~[akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:212) ~[akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506) [akka-actor_2.10-2.1.4.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.10.2.jar:na]
15:43:18.929 [INFO ] i.g.h.a.HttpRequestAction - Sending request ‘request_7’: scenario ‘Scenario Name’, userId #0
15:43:19.156 [TRACE] i.g.h.a.AsyncHandlerActor -
Request:
request_7: OK