Add cookie to scenario, problem with syntax

Hi, I need to send one GET request with cookie
I don’t understand the right syntax

//
val saleScn = scenario(nameSaleScn)
  .exec(
    http("Send sale json")
      .post(postHistory)
      .param(saleParam, generateSaleJson(userId, shopId, 2, limit))
      .check(status.is(200))
  ).pause(30 seconds)

where do i have to put:

addCookies("", Cookie(domain, “cookie_name”, cookieValue, “/”))

this doesn’t work, code can’t be compiled
http://gatling.io/docs/2.0.2/http/http_helpers.html

.exec(addCookie(Cookie("name", "value")))

I get: not found: value addCookie from compiler

So the doc says exec(addCookie(Cookie(…
and you write exec(addCookies("", Cookie(

Are you sure you can’t spot anything wrong here?

Hi, thanks for the reply.
I tried both ways.

al saleScn = scenario(nameSaleScn)
  .exec(addCookie(Cookie("", "my_cookie_name", cookieValue, "/"))
    http("Send sale json")
      .post(postHistory)
      .param(saleParam, generateSaleJson(userId, shopId, 2, limit))
      .check(status.is(200))
  ).pause(30 seconds)

not found: value addCookie

18:45:54.230 [main][ERROR][ZincCompiler.scala:98] i.g.a.ZincCompiler$ - .exec(addCookie(Cookie("", “my_cookie_name”, cookieValue, “/”))

What do I do wrong?

hi, copy-pasting from root question:

this doesn’t work, code can’t be compiled
http://gatling.io/docs/2.0.2/http/http_helpers.html

.exec(addCookie(Cookie("name", "value")))

*I get: not found: value addCookie from compiler*

https://github.com/gatling/gatling/blob/master/gatling-http/src/test/scala/io/gatling/http/HttpCompileTest.scala#L212

Thanks!


.exec(addCookies("", Cookie("my.domain.com", "cookie_name", cookieValue, "/")))
.exec(
  http("Send sale json")
    .post(postHistory)
    .param(saleParam, generateSaleJson(userId, shopId, 2, limit))
    .check(status.is(200))
).pause(30 seconds)

only this one works…
Problem is solved.

If you have some bootstrap._ import, it means that you’re using an old version, which is no longer maintained.
Please upgrade.

Now 15 errors :slight_smile:
Thanks, trying to fix it. I’ve used 2.0.M3 maven-plugin it was my fault :frowning:

You shouldn’t be using anything in the old Excilys maven repository.
Everything is in maven central now.

Aha, I’ve excluded them, it works.
Now gatling stopped to post data

val historyScn = scenario(nameHistoryScn)
  .repeat(limit){
  feed(generateFeeder(userId, shopId, limit).queue)
    exec(
      http("Setting up data for test")
        .post(postHistory)
        .queryParam(visitParam, "${visit}")
        .check(status.is(200))
    ).pause(5 seconds)
  }

I get No attribute named ‘visit’ is defined
feeder returns an array of maps:
Map(visit → {“json_here”})

val visitParam="visit"

What’s wrong now…? I’ve tried formParam, it also doesn’t work.

Because you didn’t properly chain feed and the following exec with a dot.

It compiles both ways so confuses a little non-scala user.
Thanks. so cool, it works!