Playwright / Quiz

Login at API Speed

POST the credentials, capture the cookies, export storageState, and boot every browser test pre-authenticated, plus the localStorage-token case the trick cannot cover.

Difficulty
Medium
Format
Quiz
Points
150
Estimate
9 min

// MISSION BRIEF

Your Mission

The storageState pattern usually gets demoed with a UI login. The faster version never opens a browser at all: a request context logs in over HTTP, its cookie jar captures the session, and storageState exports it for every browser test to reuse.

Six questions on the API-first auth bootstrap and its edge cases. Speed bonus active.

// FIRST CONTACT

Battle teaser

The API-login bootstrap, end to end:

  1. ATests share one global page that stays logged in
  2. BPlaywright auto-detects login forms and fills them
  3. CYou paste a session cookie from devtools into the repo
  4. DA setup step POSTs credentials via a request context; Set-Cookie responses land in its cookie jar; requestContext.storageState({ path: 'auth.json' }) exports them; browser tests load the file via use: { storageState }
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

playwrightauthenticationapi-testingstoragestate