Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a cookie for a Gatling scenario

I have the following code. The problem is that the cookie is not being set for the requests that follow.

I would like to set a single cookie that is used by all of the subsequent requests (including the ajaxRequests).

val get = scenario("Page")
  .feed(myfeed)
  .group("Home Page") {
    exec(session => setSessionVariables(session))
      .exec(addCookie(Cookie("mycookie", "true").withDomain(baseurl)))
      .exec(http("Home Page")
        .get(pageUrl)
        .resources(
          ajaxRequest01,
          ajaxRequest02
        ))
  }
like image 954
Questioning Avatar asked Nov 20 '25 04:11

Questioning


1 Answers

My best guess is that the problem here is that the baseUrl you are using includes the protocol - e.g. https://www.google.com/ etc.

From my experimentation with this feature, this won't work, the cookie needs to be passed just the domain - e.g. www.google.com or just .google.com if you want it to apply across subdomains.

like image 180
jimmycliffface Avatar answered Nov 22 '25 17:11

jimmycliffface



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!