xehpuk
January 18, 2026, 2:43am
1
Gatling version : 3.14.9.5
Gatling flavor : java kotlin scala javascript typescript
Gatling build tool : maven gradle sbt bundle npm
Hello!
I’d like to save a value only when I’m at a specific location. This doesn’t work:
http("Test")
.get("https://example.org")
.check(
currentLocation().saveAs("current_location"),
// 1st problem: can't have `doIf` here
doIf(session -> session.getString("current_location").equals("..."))
.then(css("#id", "attribute").saveAs("value")), // <- 2nd problem: required: Executable, actual: Final
)
How would I do that?
xehpuk
January 18, 2026, 7:12pm
3
Hi, Stéphane,
It looks like this with checkIf:
http("Test")
.get("https://example.org")
.check(currentLocation().saveAs("current_location"))
.checkIf(session -> session.getString("current_location").equals("..."))
.then(css("#id", "attribute").saveAs("value"))
My question wasn’t complete, my apologies. My brain was already steaming.
Not only do I want to save something, I also want to send an extra HTTP request in this case.
Send request A. There can be response 1 or 2.
If it’s response 1, save some stuff and send request B. Request B will give me response 2.
Send request C with data from response 2. Response 2 will either come from request A or B.
How to model the sometimes optional request B?
With a doIf as the next element of the chain.
Hi,
Save the current position in a.check(), and then use doIf outside to get:
exec(
http(“Test”)
.get("https://example.org")
.check(currentLocation().saveAs("current_location")),
doIfEquals("#{current_location}", "…").then(
http("Conditional Check")
.get("https://example.org")
.check(css("#id", "attribute").saveAs("value"))
)
)
If you want to control flow, don’t mix capture and doIf in the same check.
xehpuk
January 23, 2026, 11:24pm
6
Doing it like that, I would lose response 2 from request A, wouldn’t I? Do I have to duplicate the checks for both scenarios?