saveAs("var")

Hello Remi,

Lowering the root level to DEBUG will only print the HTTP requests and responses, not the Session content.
Maybe we should add some DEBUG and TRACE logs to help debugging.

Until then, you can debug your Simulation with a Session function:
https://github.com/excilys/gatling/wiki/Session#wiki-functions

Regarding your wanting to select a random entry among a check result, you have to:

  1. ensure you capture ALL the results of your regex, not only the first one (which is the default): use findAll: https://github.com/excilys/gatling/wiki/Checks#wiki-extracting
  2. use a transform step in your check in order to save only one of the results: https://github.com/excilys/gatling/wiki/Checks#wiki-transforming
    So, you’ll have something like this:

val randomData = new org.apache.commons.math3.random.RandomDataImpl

val selectRandomElementInList = (list: List[String]) => {
val randomIndex = randomData.nextInt(0, list.size - 1)
list(randomIndex)
}



check(regex(“XXXXXX”).findAll.transform(selectRandomElementInList).saveAs(“idnr”))

And voila, you can use ${idnr}.

Cheers,

Stéphane

2012/8/12 Remi <reemstestcentre@gmail.com>

Hello Stephane,

thanks for your reply.
unfortunately i am getting an error:

Collecting simulations…
Exception in thread “main” java.lang.RuntimeException: Compilation failed:
C:\projecten\tools\gatlin\gatling-charts-highcharts-1.2.5\user-files\simulations\Simulation1.scala:54: error: type mismatch;
found : List[String] => String
required: Seq[String] => ?
.check(regex("""<a href="/video/([^"]*)""").findAll.transform(selectRandomElementInList).saveAs(“idnr”))
^
one error found

do you know what’s going wrong?

at com.excilys.ebi.gatling.app.Gatling$$anonfun$compile$1.apply(Gatling.scala:182)
at com.excilys.ebi.gatling.app.Gatling$$anonfun$compile$1.apply(Gatling.scala:172)
at com.excilys.ebi.gatling.core.util.IOHelper$.use(IOHelper.scala:24)
at com.excilys.ebi.gatling.app.Gatling.compile(Gatling.scala:172)
at com.excilys.ebi.gatling.app.Gatling.start(Gatling.scala:103)
at com.excilys.ebi.gatling.app.Gatling$.main(Gatling.scala:69)
at com.excilys.ebi.gatling.app.Gatling.main(Gatling.scala)
Press any key to continue . . .

My fault.
As the compiler states, findAll returns a Seq[String], not a List[String].
You just have to change the selectRandomElementInList signature:

val selectRandomElementInList = (list: Seq[String]) => {

val randomIndex = randomData.nextInt(0, list.size - 1)

list(randomIndex)

}

Cheers,

Steph

2012/8/12 Remi <reemstestcentre@gmail.com>

It looks like it works.

thanks a lot!
i will check it in the morning again.

Can you please help…?
I used below code.

check(bodyString.saveAs(“BODY”))

how can i print BODY in console window or how can i verify the value that stored in BODY?

Thanks & Regards,
Sathya