sincecutoff.com
← all changes

Browser.newContext() accepts multiple HTTP credentials

Introduced 2026-09-04 · score 0.95

HOW TO USE IT

When browser tests need different HTTP credentials by request origin, pass an array of credential objects to `browser.newContext({ httpCredentials })`. The first entry matching the request origin is used; an entry without `origin` matches any request.

const context = await browser.newContext({ httpCredentials: [ { username: "<user-1>", password: "<password-1>", origin: "https://<host-1>:<port>" }, { username: "<user-2>", password: "<password-2>", origin: "https://<host-2>:<port>" }, ], });

WHY THIS HELPS

Run browser tests against an application using different HTTP credentials for different request origins.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.63.0
  • httpCredentials: An object or array of objects containing HTTP authentication credentials. For an array, the first entry matching the request origin is used; an entry without `origin` matches any request.
  • httpCredentials[].username (required): Username for HTTP authentication.
  • httpCredentials[].password (required): Password for HTTP authentication.
  • httpCredentials[].origin: Restricts sending credentials to the specified origin (`scheme://host:port`).
  • httpCredentials[].send: For corresponding APIRequestContext requests, `always` sends credentials on each API request; `unauthorized` sends them after a 401 with `WWW-Authenticate`. Defaults to `unauthorized`.
  • The first entry matching the request origin is used; entries without an origin match any request.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card