Appearance
TEST.getRequestHeader()
Retrieves the value of a single HTTP request header configured on the browser proxy.
If the header is present, its string value is returned. If the header has not been set or was previously deleted, null is returned.
INFO
Header name matching is case-insensitive (e.g. "authorization" matches "Authorization").
Usage
js
let value = TEST.getRequestHeader(name)
let value = TEST.getRequestHeader(name, options)Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Required. Name of the HTTP request header to retrieve. Must be a non-empty string. |
options | object | Optional configuration options (see below). |
Options Object
| Option | Type | Description |
|---|---|---|
msg | string | Custom description message displayed for this step in the test report. |
Returns
string | null
- Returns the header's string value if configured.
- Returns
nullif the header is not set on the proxy.
Variants
TEST.getRequestHeader(): Standard execution. Logs the step to the test report and throws an error ifnameis empty or if the proxy fails.TEST.getRequestHeader$(): Error suppression mode. If an error occurs, catches the error and returnsnullwithout failing the test step.TEST.getRequestHeader$$(): Silent mode. Suppresses errors and hides the command step from the test report logs.
Examples
Check and Apply Fallback Header
js
// Check if Shopify access token is set; configure default if missing
let token = TEST.getRequestHeader("X-Shopify-Access-Token")
if (!token) {
TEST.log.info("Token not found, setting fallback test token")
TEST.setRequestHeader("X-Shopify-Access-Token", "shpat_fallback_token_123")
}Validate Authorization Token Value
js
let auth = TEST.getRequestHeader("Authorization")
if (auth && auth.startsWith("Bearer ")) {
TEST.log.pass("Valid Bearer token is attached to browser proxy")
} else {
TEST.log.fail("Missing or invalid Bearer token")
}Provide a Custom Step Message
js
let envHeader = TEST.getRequestHeader("X-Environment", {
msg: "Inspect active environment routing header"
})