You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Set Extra HTTP Headers keyword to change request headers mid-test #5115
Extra HTTP headers (auth tokens, correlation/tracing IDs, tenant selectors, feature-flag headers) can currently only be set once, at New Context time via extraHTTPHeaders. When a test obtains a fresh token mid-session — after login, after a token refresh, or when switching users — the only way to change headers today is to close the context and create a new one, which throws away all page state, cookies and open pages. Playwright allows updating the headers on a live context (or page) at any time; the library should too.
Proposed keyword / arguments
Set Extra HTTP Headers &{headers} *, scope=Context
headers — free named arguments (or a dict) of header name → value; applied to all subsequent requests. Header values must be strings.
scope — Context (default): headers apply to every page in the current context, including pages opened later; Page: only requests initiated by the current page (page-level headers are merged over context-level ones, per Playwright semantics).
New ContextNew Page${URL}/login
# ... perform login, obtain a token ...Set Extra HTTP Headers Authorization=Bearer ${token} X-Correlation-Id=${test_id}Go To${URL}/dashboard
# Override for the current page onlySet Extra HTTP Headers X-Experiment=variant-b scope=Page
New RPC in protobuf/playwright.proto carrying the header map plus a page/context flag.
node/playwright-wrapper: resolve current page or context from the catalog, call setExtraHTTPHeaders.
Python keyword (natural home: Browser/keywords/network.py or playwright_state.py), docs, atest asserting the header arrives server-side (test app echoes request headers) and that scope=Context covers a page opened after the call.
Backwards compatibility
Purely additive: a new keyword; the existing New Context extraHTTPHeaders= argument is untouched and simply provides the initial value the keyword can later replace.
Activity