Expression language variables as the parameter


I am trying to encode the component:

.get("/search.jspa?peopleEnabled=true&q=" + EncodeURIComponent.encodeURIComponent("${queryterm}"))

EncodeURIComponent.scala ecode the given terms. And ${queryterm} is defined in the searchterms.csv:

Horn west Presidential
phase noted promotion ring
Congo correspond elastic
costs crack resident

But what i get from the gatling log is like below, seems like the el does not work properly in this cal:

GET https://…baseurl…/search.jspa?peopleEnabled=true&q=%24%7Bqueryterm%7D

Is there something wrong I am doing here?



You’re trying to mix EL and programatic code, and that doesn’t work.
If you’re familiar with Scala: methods actually take Expressions (type alias for Session => Validation), and there’s an implicit for converting Strings into Expressions.

Here, “/search.jspa?peopleEnabled=true&q=” + EncodeURIComponent.encodeURIComponent("${queryterm})" is only evaluated once, when the Scenario is built.

What you want is (Gatling 2 master syntax):
session => “/search.jspa?peopleEnabled=true&q=” + EncodeURIComponent.encodeURIComponent(session(“queryterm”).as[String])

Depending on the version you use, the syntax for getting a session attribute might be different.


.get("/search.jspa?peopleEnabled=true&q=" + EncodeURIComponent.encodeURIComponent("${queryterm}"))

What this line does is, create the get() call with the following URL : “search.jspa?peopleEnabled=true&q=%24%7Bqueryterm%7D”
Indeed, you have encoded “${query term}”, so it’s not interpreted at runtime.

The following will be working :

.get("/search.jspa?peopleEnabled=true}).queryParam(“q”, “${queryterm}”)

This works, Thx!