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
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 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.
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.
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.
Go Deeper on Browser Context
Know the term. These are the courses that turn the concept into something you can demonstrate.
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.
Which terms relate to Browser Context?
Explore related glossary terms to deepen your understanding.
Related Resources
Dive deeper with these related interview prep pages.
Free QA career tools, no account needed
Instant and private, everything runs in your browser. Try them before you sign up.
QA Resume Checker
Instant 0-100 score on automation keywords, impact, and ATS formatting.
QA Cover Letter Generator
A tailored 3-paragraph QA cover letter from your resume and a job post.
QA Application Tracker
Drag-and-drop kanban to track every QA application from Applied to Offer.
QA Take-Home Test Generator
A realistic take-home assignment with a scenario, tasks, and a rubric.
QA LinkedIn Headline Generator
A recruiter-searchable headline, About section, and skills list.
QA STAR Story Builder
Structure a QA behavioral answer with the STAR method and instant checks.
QA Bug Report Generator
Build a clean, reproducible bug report for Markdown, Jira, or plain text.
Boundary Value Analysis Generator
Generate boundary value and equivalence partitioning test cases from a range.
QA Metrics Calculator
Calculate DRE, defect leakage, defect density, and pass rate with interpretation.
QA Test Plan Generator
Build a structured test plan (scope, approach, criteria, risks) in Markdown.
QA Salary Calculator
Estimate QA, SDET, and automation tester pay by level, market, and skills.
QA Offer Evaluator
See total comp, a counter range, and a ready-to-send negotiation message.
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.
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