Skip to content

TEST.getRequestHeaders() ​

Retrieves all global HTTP request headers currently configured on the browser proxy.

Returns an object map containing all active header names and values. If no custom request headers are configured, it returns an empty object {}.

Usage ​

js
let headers = TEST.getRequestHeaders()
let headers = TEST.getRequestHeaders(options)

Parameters ​

ParameterTypeDescription
optionsobjectOptional configuration options (see below).

Options Object ​

OptionTypeDescription
msgstringCustom description message displayed for this step in the test report.

Returns ​

An object map (Record<string, string>) of all currently active proxy request headers.

javascript
{
    "Authorization": "Bearer token_xyz",
    "X-Environment": "staging"
}

If no headers are configured, returns {}.

Variants ​

  • TEST.getRequestHeaders(): Standard execution. Logs the step to the test report and returns the active headers map.
  • TEST.getRequestHeaders$(): Error suppression mode. Catches proxy communication errors and returns null instead of failing the test.
  • TEST.getRequestHeaders$$(): Silent mode. Suppresses errors and hides the command step from the test report logs.

Examples ​

Inspect Active Headers ​

js
// Retrieve all active headers
let headers = TEST.getRequestHeaders()

// Check if an Authorization header is active
if (headers["Authorization"]) {
    TEST.log.info("Test running with active authorization token")
} else {
    TEST.log.info("Test running in unauthenticated mode")
}

Log Active Headers to the Test Report ​

js
let headers = TEST.getRequestHeaders()
TEST.log.info("Active proxy headers: " + JSON.stringify(headers))

Custom Step Message ​

js
let headers = TEST.getRequestHeaders({
    msg: "Inspect active proxy headers before checkout"
})