Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gatling/gatling.io-doc/llms.txt

Use this file to discover all available pages before exploring further.

Gatling’s check system validates response data and optionally captures values into the virtual user’s session for use in subsequent requests. The HTTP module provides a set of built-in check targets that cover the full range of HTTP response attributes — from the status code and response headers to the final URL after redirects and the full response body. HTTP-specific checks compose with the same is, not, in, exists, notExists, saveAs, and name operators available to all Gatling checks.
If you don’t define an explicit status check on HTTP requests or the HTTP protocol, Gatling performs an implicit check that verifies the response status code is 2XX or 304.

Status Code

Target the HTTP response status code with status(). The most common use is asserting an exact value, but you can also use in, not, and saveAs.
http("name").get("/")
  .check(status().is(200));

// save the status code into the session
http("name").get("/")
  .check(status().saveAs("status"));

Page Location

currentLocation

Targets the absolute URL of the final page after all redirects have been followed. Useful for verifying that redirects land on the expected destination.
http("name").get("/")
  .check(currentLocation().is("https://example.com/landing"));

http("name").get("/")
  .check(currentLocation().saveAs("url"));

currentLocationRegex

Applies a Java regular expression to the final URL. Use captureGroups(n) when your pattern contains multiple capture groups; the result is a List of the captured strings.
http("name").get("/")
  .check(
    // single capture group
    currentLocationRegex("https://(.*)/.*")
      .saveAs("domain"),
    // multiple capture groups
    currentLocationRegex("http://foo.com/bar?(.*)=(.*)")
      .captureGroups(2)
      .saveAs("queryParamKeyAndValue")
  );

HTTP Headers

Targets a single response header by name. The check succeeds if the header is present and passes all applied conditions. The header name parameter accepts static strings, Gatling EL strings, and functions.
http("name").get("/")
  .check(header("Content-Encoding").is("gzip"));

headerRegex

Applies a Java regular expression to a specific response header’s value. Use captureGroups(n) to extract multiple groups.
http("name").get("/")
  .check(
    headerRegex("FOO", "foo(.*)bar(.*)baz")
      .captureGroups(2)
      .saveAs("data")
  );

Body Checks

Body checks are part of the core Gatling check system and are fully usable on HTTP responses. The following extractors are available:

regex

Applies a Java regular expression to the response body string. Supports find, findAll, findRandom, and count.

xpath

Evaluates an XPath expression on XML or HTML response bodies. Supports namespace declarations.

jsonPath

Evaluates a JSONPath expression on JSON response bodies using the Jayway library.

jmesPath

Evaluates a JMESPath expression on JSON response bodies using the JMESPath Java library.

css

Applies a CSS selector (jQuery-style) to HTML response bodies. Can target element attributes.

bodyString

Captures the entire response body as a String.

bodyBytes

Captures the entire response body as a byte array.

bodyLength

Captures the response body length in bytes as an integer.

Body Check Examples

http("name").get("/")
  .check(regex("user_(.*)").saveAs("userId"));

// find all matches
http("name").get("/")
  .check(regex("item_([0-9]+)").findAll().saveAs("itemIds"));

Combining Multiple Checks

You can chain multiple checks on a single request. All checks must pass for the request to be considered successful.
http("Create User").post("/api/users")
  .asJson()
  .check(
    status().is(201),
    header("Location").exists(),
    jsonPath("$.id").saveAs("newUserId"),
    jsonPath("$.name").is("#{expectedName}")
  );

Protocol-Level Checks

Checks can also be defined on the HttpProtocol with .check(checks...) to apply them to every request in the scenario. Individual requests can override this with ignoreProtocolChecks.
See the HTTP Protocol reference for how to attach checks to the protocol builder.

Build docs developers (and LLMs) love