Calling headerRegex throws implicit value exception

I am trying to run gatling test where it logs in and checks and store the value of a cookie.

Here’s the code snippet that I have:

.pause(minWait, maxWait)
.feed(usernames)
.exec(
http("_pLoginForm_Basic")
.post("${postUrl}")
.headers(headers_0)
.formParam(“username”, “${username}”)
.formParam(“password”, “test123”)
.check(status.is(200),
headerRegex(“Set-Cookie”, “viafoura_session_id”)
.ofType[(String, String)]
.saveAs(“vf_sess_id”)
)
);
The login and status check part is working fine, but headerRegex always give me the following error during execution:

07:55:03.140 [main][ERROR][ZincCompiler.scala:141] i.g.c.ZincCompiler$ - /home/crengga/projects/vi-vinl/vinl-gatling/src/test/scala/nl/vi/gatling/simulation/OpenSessionsInitializer.scala:63: could not find implicit value for parameter extractorFactory: io.gatling.http.check.header.HttpHeaderRegexExtractorFactory

Am I missing some imports or declarations in my gatling (scala) class?

Not sure if this’ll help much, as I’ve never had to use a header regex, but your second parameter in:

headerRegex(“Set-Cookie”, “viafoura_session_id”)

doesn’t look much like a regex pattern to me, eg. (.+?) or whatever, which could explain the exception headline.

A quick Google search reveals someone else’s usage as:

.check(headerRegex("Set-Cookie","student_id=(.*); path=/").saveAs("student_id"))

What format does your ‘viafoura_session_id’ cookie have (in a response)? Feel free to paste here.

Hi, I tried to do what you posted and it’s still not working:

.check(status.is(200),
headerRegex(“Set-Cookie”, “.*”).saveAs(“vf_sess_id”)
)

This also doesn’t work, also with path=/

My viafoura_session_id cookie’s value looks like this:

vi_766d55978a987c9feb2f05bc51afe90b72eb06687b226fd2e640007cac351683_b358e52f-9fb6-4c81-9875-8fa2ffdd7da9

The error was turns out to be wrong way of importing the classes. Since I relied on intellij’s auto import, it did not import all needed classes.

Previously was like this:

import io.gatling.http.Predef.{currentLocationRegex, headerRegex, http, regex, responseTimeInMillis, status}

And I changed it to

import io.gatling.http.Predef._