Builder multiValuedParam directly from checker 'findAll' method

Hello,

I’m building a scenario for populating dynamically generated forms. I’m stuck with an issue implementing data from multi valued checkboxes, with the same name attributes.

I’d written a checker with css :

css(""“input[type=checkbox][name=”"""+name+""""]:checked""", “value”).findAll.whatever.saveAs(sessionAttribute)

The check seems to work as I can printout values from sessionAttribute. It’s a ArrayBuffer

Later on my scenario I want to post back the values to the server and I can’t get multiValuedParam to work as in the wiki example

What works
//hardcoded, juste for testing purpose
builder = builder.multiValuedParam(fieldName, Seq(“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“11”,“12”))

works but post empty string values for out of range keys :
builder = builder.param(fieldName, “”"${"""+sessionName+"""(0)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(1)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(2)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(3)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(4)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(5)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(6)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(7)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(8)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(9)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(10)}""")
builder = builder.param(fieldName, “”"${"""+sessionName+"""(11)}""")

Dont work and throw a warning like “Couldn’t resolve EL ${xx[xx][xx][xx][2010][]}” :
builder = builder.multiValuedParam(fieldName, “”"${"""+sessionName+"""}""")

Am I missing something on the building of multivalued parameters ?

Best regards,
Benoit

Hi Benoit,

You’re missing the point that the DSL elements are immutable (that’s the only way to have them reusable in different places)!
So, you either have to declare your builder as a var and reassign it, or use a fold:

val newBuilder = (1 to 11).foldLeft(builder) { (cur, i) => cur.param(fieldName, “${”+sessionName+"(" + i + “)}”) }

Cheers,

Stéphane

Thank you Stéphane this works and is much more readable than examples I provided, I understand builder is immutable and I need either to reassign it or make it a var.

However, it adds extra parameters that are not in the ArrayBuffer value in session, which is why I wanted to use the syntax as in documentation and pass the whole list at once

multiValuedParam("omg", "${foo}")) // where foo is the name of a Seq Session attribute

Currently I got those warnings for elements not found “Couldn’t resolve EL ${xx[xx][xx][xx][xx]}” and it puts an empty parameter to the builder.

I agree this is what the code is supposed to do, but could show me a working example with an entire list or tell me it its not the same kind of value I got from checker’s findAll method and I need to transform it first ?

Cheers
Benoit

2013/3/18 Stéphane Landelle <slandelle@excilys.com>

Your “xx[xx][xx][xx][xx]” is a very weird name for a session attribute. Are you sure that’s what you expect? What’s sessionName in “builder = builder.multiValuedParam(fieldName, “””${"""+sessionName+"""}""")", compared to “sessionAttribute”?

Having a gist would help.

Cheers,

Stéphane

sessionName is the same string as fieldName for this one, I know its weird naming (the xx are here to shorten it but real name is kinda long) but the app I want to stress test has a lot of forms with many fields with dynamic naming, so storing session values with form field name as key seems the most maintanable way to me.
On simple values (ie not lists) for text input or checkboxes this was not an issue

Yes I’m sure I want to post the only values extracted from css checker, otherwise the form validation fails on my app (as browsers do not post unchecked checkboxes values) and the scenario cannot continue well.

I created a simplified version of the scenario on https://gist.github.com/anonymous/cb09e9a94deafd5d44a8 , the snippet you gave me is line 117

All fields are stored in a map with keys to access them, the multiple checkboxes I want to use is aliased “date|_” and field name generated depending on current year (36 fields for 36 months back).

The code for extractCheckboxMultipleValue helper is available here https://gist.github.com/anonymous/62c55b4ea4d42ce3fe34

Thank you

2013/3/19 Stéphane Landelle <slandelle@excilys.com>

What does println(session) logs?

Among the rest of scenario data I got

antecedents[conducteur_principal][repartition_periodes][periode_assurance_2013][2013][] → ArrayBuffer(1, 2),
antecedents[conducteur_principal][repartition_periodes][periode_assurance_2010][2010][] → ArrayBuffer(3, 4, 5, 6, 7, 8, 9, 10, 11, 12),

antecedents[conducteur_principal][repartition_periodes][periode_assurance_2012][2012][] → ArrayBuffer(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),

antecedents[conducteur_principal][repartition_periodes][periode_assurance_2011][2011][] → ArrayBuffer(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),

2013/3/19 Stéphane Landelle <slandelle@excilys.com>

I think I get it.
In Gatling 1.x, the EL engine is not able to resolve other things than Strings (it is in Gatling 2). So, unlike what the doc states, multiValuedParam(String, String) second parameter is not and EL but the name of the attribute.
Could you confirm and try builder.multiValuedParam(fieldName, sessionName), please?

Yes you get it ! I’m on 1.4.2 at the moment, and did not understand well the multiple signature of multiValuedParam. I used the first one and it works perfectly for this case.

def multiValuedParam(key: EvaluatableString, value: String): B
def multiValuedParam(key: EvaluatableString, values: Seq[String]): B
def multiValuedParam(key: EvaluatableString, values: EvaluatableStringSeq): B

Thank you for your time Stéphane

Cheers,
Benoit

2013/3/19 Stéphane Landelle <slandelle@excilys.com>

I fixed the doc.

Sorry for this mess,

Stéphane