Playwright · Reliable end-to-end tests

What is a browser context?

Easybrowser contextisolationfixturesUpdated Oct 2026
Quiz this track

Short answer

A browser context is an isolated, incognito-like session inside a browser. It has its own cookies, localStorage, cache and permissions, and each Playwright test gets a fresh one.

A browser context is the unit of isolation. Opening a page always happens inside a context, whether you create it explicitly or let the test fixture do it. Two contexts in the same browser cannot see each other's cookies, localStorage or cache.

ts
const context = await browser.newContext({
  viewport: { width: 412, height: 915 },
  locale: "en-IN",
  timezoneId: "Asia/Kolkata",
  permissions: ["geolocation"],
});

const page = await context.newPage();
await context.close();
Context options shape emulation, permissions and locale for every page inside it.

What a context isolates

  • Cookies and localStorage
  • Cache and service workers
  • Viewport, locale, timezone and permissions
  • Extra HTTP headers and authentication credentials
  • Network routing registered on that context

Contexts are much cheaper than browser processes. That is why Playwright can give every test a clean context while reusing a browser per worker. Creating a new browser for every test would be slower and provides little additional isolation for normal web tests.

A context does not isolate server-side state. If two tests share a database row, a cache key or an account, they can still interfere even when their browser contexts are separate.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Why is a context cheaper than a browser?
  2. 2How do you set a locale or timezone for a context?
  3. 3Does a context isolate server-side data?
  4. 4How does the page fixture create a context?

Say it in the interview

A browser context is an isolated session inside a browser, roughly like an incognito profile. It has its own cookies, localStorage, cache and permissions, and Playwright gives each test a fresh one. Contexts are cheap, so we reuse a browser per worker but not the session state. They do not isolate backend data, so I still need unique test data when tests share a server.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Playwright mock interview and get scored feedback on depth, clarity and confidence.