Browser tests can now set an HTTP header partway through a test with the new Set HTTP header step. From that step on, the browser sends the header on every request it makes for the rest of the test: page loads, scripts, images, fetch and XHR calls, and new tabs. The name and value both accept variables, so you can capture a value in an earlier step and send it as a header on everything that follows.
Plan-level custom HTTP headers are fixed when you configure the plan. The Set HTTP header step covers the cases they can't:
-
Runtime-computed values: Call your API in an API step, save the token or session ID to a variable, then send it as
{{@token}}on every browser request from that point on. - Per-test headers: Send a tenant ID, feature flag, or routing header for a single test without changing the plan. Plan-level custom headers still apply alongside it.
- Changing a header mid-test: Set the same header again later in the test and the new value replaces the old one. Header names are case-insensitive.
The header value never appears in run logs or test output.
Try it out
- Open a browser test in the latest version of the mabl Desktop App, or in quick edit in the mabl app.
- Click + (Add step) > HTTP header.
- Enter the Header name and Header value. Both fields accept variables with the
{{@variable_name}}syntax. - Click OK. mabl sends the header on every browser request after this step until the test ends.
You can also ask the mabl agent to add the step while it builds a test, for example: "After the login API call, send the returned token as the x-session-token header on every request."
If you run tests with the mabl CLI, update to version 2.141.10 or later.
The Set HTTP header step applies to browser requests only. API steps in the same test keep the headers defined on each step, and the step is not available in mobile or API tests. The step cannot set the Proxy-Authorization header.