Default value saving as result on check


i need to parse form data and send them in next request. I wrote sth like this:

def checkInputValue(name: String) =
check(regex(""“name=”.*""" + name + “”"[^"]+".+value="([^"]+)""").whatever.saveAs(name))
.doIf(session => !session(name).validate[String]) {
session.set(name, " ")

And in main file:

.exec(http(“display form”)

.exec(http(“send form”)
.param(“var1”, “${var1}”)
.param(“var1”, “${var2}”)

param(“var1”, “${varN}”)

How can I do sth like this?
I try to use only whatever function, but where input value is not set (value tag doesn’t exists) I get an error:

No attribute named X’ is defined

I don’t want to put doif in my scenario always after .check.

Thanks for your help,


What about using the following structure :

regex(""“name=”.*""" + name + “”"[^"]+".+value="([^"]+)""")



I realize this is an older post but I was wondering if you could help me out a bit with this. I’m using jsonPath where one of the values I want to get might be null. If it is, I want to default to a String 0.00. I tried to use something similar to your example (Some(“0.00”)) but the compiler says it requires a PartialFunction. I realize this is probably a general Scala question but I can’t seem to find much helpful information

Which version do you use?

I’m using 1.5.5

So this thread was about Gatling 2.
Sadly, you can’t achieve default values with Gatling 1 API.

Ah okay. Well, bummer

So, a follow up question then :stuck_out_tongue: . Before I found this post I was trying something similar to the following:


And then further in the execution plan:

exec(session => {
if (!session.isAttributeDefined(“taxAmt”)) {
session.setAttribute(“taxAmt”, “0.00”)

But when I dump the session I don’t see the taxAmt attribute. Is there a way to programmatically add session attributes besides saveAs

Ah, yes, you’re right, you could do that in 2 steps!

You’re problem is that Session is immutable, as explained in the documentation, so setAttribute returns a new instance.

exec(session => {
if (!session.isAttributeDefined(“taxAmt”)) {
session.setAttribute(“taxAmt”, “0.00”)
} else {

D’oh! I forgot that it was immutable. Thanks for the help!

You’re welcome!

Hi Nicolas,

I tried using your solution and I am getting below error on this :

00:08:33.596 [ERROR] i.g.c.ZincCompiler$ - C:\Users\dball83\Downloads\gatling-charts-highcharts-bundle-3.3.1-bundle (1)\gatling-charts-highcharts-bundle-3.3.1\user-files\simulations\computerdatabase\ShopSite_Scripts\CheckoutService.scala:76:57: type mismatch;
found : Some[String]
required: PartialFunction[?,?]

Can you please take a look here

First, you want to use transformOption, not transform, see documentation:

Then, there’s a limitation in the checks design in Gatling 3 that forces users to have to make transform input type explicit, see This will be fixed in Gatling 3.4.

Thanks @stephane, This is working for me