Is there a way to use a variable that was captured with RegEx and
saved using saveAs?
Here is my module:
object GetInfo {
val scnOne = scenario("Get Book Size and Id")
There are multiple matches and they are being saved as List values
into variable bookSelectionUrl.
How can I print this values out? Or how can I choose one of them?
What I need, I need to be able to select 4th selection?
i now want to readout idnr. this should contain multiple values, because the regex matches multiple times.
according to the explanation, this should be a session. but i cannot read it out or display it via println.
hopefully you can help me.
Yep, you’ve used saveAs(“idnr”), which means that you’ve saved the outcome of your regex (in your case, a List[String] as you used findAll) into the Session as an attribute named “idnr”.
You can then retrieve this attribute either with an EL inside a String parameter, or programmatically with a Session function.
EL means Expression Language. Gatling EL syntax is very similar to the Java one.
Could you explain what you mean by “it doesn’t work”, please? Do you get an exception? Except this EL problem, does your simulation work fine?
Could you post a Github gist with your whole Simulation?
C:\Projecten\testtools\gatling-charts-highcharts-1.2.5\user-files\simulations\Simulation.scala:84: error: not found: value session
.exec((session: Session)
^
one error found
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)
Druk op een toets om door te gaan. . .
lowering the root level to DEBUG doesn’t print the value of the session attribute idnr
actually my regex works, only problem it’s retrieving the first match.
to make the performance test more realistic i want it to return a random match.
so i am using this session attribute idnr now as ${idnr} in a getrequest
but when i use it like ${idnr[3]}
it gives an error back.