arrow-left Back to topicQuizIsolationCheck yourself1.Test A logs in as admin, sets a session cookie, and passes. Test B (which tests the login page) starts immediately after. Does test B see the admin session cookie?Yes — tests share the same browser, so cookies persist between themNo — each test runs in its own isolated browser context; test B starts with zero cookies regardless of what test A didIt depends on whether the tests run sequentially or in parallel2.What is a browser context in Playwright most analogous to?A browser tab — it shares cookies and storage with other tabs in the same windowA fresh incognito window — completely isolated cookies, localStorage, and cacheA browser profile — shares extensions and bookmarks but not cookiesA separate browser process — completely isolated including network stack3.What is the correct hierarchy from largest to smallest in Playwright's browser model?Page → Context → BrowserBrowser → Context → PageBrowser → Page → ContextContext → Browser → Page4.How do you create a second browser context manually within a single test?Call page.newContext() to fork the current contextRequest the browser fixture and call browser.newContext() to create a second isolated contextUse test.extend() to declare a second context fixtureCall context.clone() to create a copy of the current context5.You want to run a test already logged in as a specific user without repeating the login flow every time. Which approach uses browser context storageState correctly?Log in in each beforeEach hook and save the session to a global variableSave auth state to a JSON file in a setup step, then set storageState to that file in the config or per testPass cookies directly to page.goto() as query parametersUse page.evaluate() to set document.cookie before each test6.What is a persistent context in Playwright and when would you use it?A context shared between all tests in a suite — used to avoid repeated browser launchesA context that launches a browser with a real user profile directory — cookies and localStorage persist to disk across sessionsA context that automatically retries failed network requestsA context that keeps its storage state between test.describe blocks7.Why is 'cleaning up state between tests' considered worse than Playwright's context isolation approach?Cleaning up is slower than creating a new contextCleanup is error-prone — you can forget items, and some browser state (like visited link styles) cannot be reset without a new contextIt requires additional test permissions that are not available by defaultPlaywright does not provide any API for clearing browser state manually8.In a test that uses browser.newContext() to create two contexts, what must you do before the test ends?Nothing — Playwright automatically closes all contexts when the test finishesCall context.dispose() on each manually created contextCall context.close() on each manually created context to release browser resourcesCall browser.close() to clean up all contexts at onceSubmit answersarrow-left PreviousAuthenticationFramesNext arrow-right