Skip to main content
Automation
DEFINITION

What is Browser Context?

A browser context is an isolated, incognito-like browser profile in Playwright. Each context has its own cookies, local storage and session storage, and many contexts can run inside one browser. Playwright creates a fresh context for every test, so state from one test cannot leak into the next.

No account needed · Scored in under a minute against a senior rubric

IN DEPTH

What does Browser Context mean in practice?

Playwright's docs call this test isolation. Each test gets its own BrowserContext and a default page inside it. Contexts are fast and cheap to create, so starting every test from a clean slate costs little.

The docs compare two strategies: start from scratch, or clean up between tests. Cleaning up is easy to forget, and some state, such as visited links, cannot be cleaned up at all. When state leaks, a test fails because of something another test did, and the debugging starts in the wrong place. Starting from scratch means a failure only needs looking at inside that one test.

In the test runner you get the context through the context fixture, next to page. Outside the runner you create one yourself: const context = await browser.newContext(), then const page = await context.newPage().

One test can also open several contexts. That is how you test multi-user features such as a chat: call browser.newContext() twice, once for an admin and once for a user, and drive each page on its own. Contexts can also emulate mobile devices, permissions, locale and color scheme.

WHY IT MATTERS

Why do interviewers ask about Browser Context?

Isolation is why a Playwright suite can run in parallel without tests stepping on each other. Interviewers ask about contexts to check that you know where test state lives, and why one failing test should never break the next.

EXAMPLE

What does Browser Context look like in a real project?

A support chat needs testing from both sides. The test opens two contexts from the same browser, one signed in as an agent and one as a customer. The customer sends a message and the test checks that it appears on the agent's page. The contexts share no cookies, so each side keeps its own session.

TIP

How should you talk about Browser Context in an interview?

Contrast a new context with a new browser launch: a context is much cheaper and still fully isolated. Then give the two-users-in-one-test example, which shows you have used the API beyond the default fixtures.

FAQ

Common questions about Browser Context

What is the difference between a browser and a browser context in Playwright?

A browser is what chromium.launch() gives you. A context is an isolated profile inside that browser, with its own cookies and storage. One browser can hold many contexts. Playwright's docs describe contexts as fast and cheap to create and completely isolated, even inside a single browser, and Playwright creates a new context for each test.

Does each Playwright test get a new browser context?

Yes. When you use Playwright as the test runner, it creates a new context for each test and gives you a default page in it. The context and page in one test are completely isolated from those in another.

Related Resources

Dive deeper with these related interview prep pages.

FREE TOOLS  /  no signup

Free QA career tools, no account needed

Instant and private, everything runs in your browser. Try them before you sign up.

EXEC.NOW

Ready to Ace Your QA Interview?

Practice explaining browser context and other key concepts with our AI interviewer.

Join 600+ QA engineers already practicing with AssertHired.

Question 1 · Automation · Mid-levellive scoring

A test passes locally but fails in CI about one run in five. Walk me through what you check first, and why.

This single answer is scored on four dimensions: Technical accuracy · Coverage · Clarity · Best practices.

Rather skip ahead? Create a free account

FREE  ·  7-DAY TRIAL
Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated October 2026