<titledata-rh="true">BrowserContext class | Puppeteer</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://pptr.dev/next/api/puppeteer.browsercontext"><metadata-rh="true"property="og:locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docsearch:counter"content="3"><metadata-rh="true"property="og:title"content="BrowserContext class | Puppeteer"><metadata-rh="true"name="description"content="BrowserContext represents individual user contexts within a browser."><metadata-rh="true"property="og:description"content="BrowserContext represents individual user contexts within a browser."><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/next/api/puppeteer.browsercontext"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.browsercontext"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.browsercontext"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://DVKY664LG7-dsn.algolia.net"crossorigin="anonymous"><linkrel="search"type="application/opensearchdescription+xml"title="Puppeteer"href="/opensearch.xml">
<p><ahref="/next/api/puppeteer.browsercontext">BrowserContext</a> represents individual user contexts within a <ahref="/next/api/puppeteer.browser">browser</a>.</p>
<p>When a <ahref="/next/api/puppeteer.browser">browser</a> is launched, it has a single <ahref="/next/api/puppeteer.browsercontext">browser context</a> by default. Others can be created using <ahref="/next/api/puppeteer.browser.createbrowsercontext">Browser.createBrowserContext()</a>. Each context has isolated storage (cookies/localStorage/etc.)</p>
<p><ahref="/next/api/puppeteer.browsercontext">BrowserContext</a><ahref="/next/api/puppeteer.eventemitter">emits</a> various events which are documented in the <ahref="/next/api/puppeteer.browsercontextevent">BrowserContextEvent</a> enum.</p>
<p>If a <ahref="/next/api/puppeteer.page">page</a> opens another <ahref="/next/api/puppeteer.page">page</a>, e.g. using <code>window.open</code>, the popup will belong to the parent <ahref="/next/api/puppeteer.page.browsercontext">page's browser context</a>.</p>
<h4class="anchor anchorWithStickyNavbar_FNw8"id="signature">Signature:<ahref="#signature"class="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"></a></h4>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="remarks">Remarks<ahref="#remarks"class="hash-link"aria-label="Direct link to Remarks"title="Direct link to Remarks"></a></h2>
<p>The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the <code>BrowserContext</code> class.</p>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="example">Example<ahref="#example"class="hash-link"aria-label="Direct link to Example"title="Direct link to Example"></a></h2>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="properties">Properties<ahref="#properties"class="hash-link"aria-label="Direct link to Properties"title="Direct link to Properties"></a></h2>
<table><thead><tr><th><p>Property</p></th><th><p>Modifiers</p></th><th><p>Type</p></th><th><p>Description</p></th></tr></thead><tbody><tr><td><spanid="closed">closed</span></td><td><p><code>readonly</code></p></td><td><p>boolean</p></td><td><p>Whether this <ahref="/next/api/puppeteer.browsercontext">browser context</a> is closed.</p></td></tr><tr><td><spanid="id">id</span></td><td><p><code>readonly</code></p></td><td><p>string | undefined</p></td><td><p>Identifier for this <ahref="/next/api/puppeteer.browsercontext">browser context</a>.</p></td></tr></tbody></table>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="methods">Methods<ahref="#methods"class="hash-link"aria-label="Direct link to Methods"title="Direct link to Methods"></a></h2>
<table><thead><tr><th><p>Method</p></th><th><p>Modifiers</p></th><th><p>Description</p></th></tr></thead><tbody><tr><td><spanid="browser"><ahref="/next/api/puppeteer.browsercontext.browser">browser()</a></span></td><td></td><td><p>Gets the <ahref="/next/api/puppeteer.browser">browser</a> associated with this <ahref="/next/api/puppeteer.browsercontext">browser context</a>.</p></td></tr><tr><td><spanid="clearpermissionoverrides"><ahref="/next/api/puppeteer.browsercontext.clearpermissionoverrides">clearPermissionOverrides()</a></span></td><td></td><td><p>Clears all permission overrides for this <ahref="/next/api/puppeteer.browsercontext">browser context</a>.</p></td></tr><tr><td><spanid="close"><ahref="/next/api/puppeteer.browsercontext.close">close()</a></span></td><td></td><td><p>Closes this <ahref="/next/api/puppeteer.browsercontext">browser context</a> and all associated <ahref="/next/api/puppeteer.page">pages</a>.</p><p><strong>Remarks:</strong></p><p>The <ahref="/next/api/puppeteer.browser.defaultbrowsercontext">default browser context</a> cannot be closed.</p></td></tr><tr><td><spanid="isincognito"><ahref="/next/api/puppeteer.browsercontext.isincognito">isIncognito()</a></span></td><td><p><code>deprecated</code></p></td><td><p>Whether this <ahref="/next/api/puppeteer.browsercontext">browser context</a> is incognito.</p><p>In Chrome, the <ahref="/next/api/puppeteer.browser.defaultbrowsercontext">default browser context</a> is the only non-incognito browser context.</p><p><strong>Deprecated:</strong></p><p>In Chrome, the <ahref="/next/api/puppeteer.browser.defaultbrowsercontext">default browser context</a> can also be "incognito" if configured via the arguments and in such cases this getter returns wrong results (see <ahref="https://github.com/puppeteer/puppeteer/issues/8836"target="_blank"rel="noopener noreferrer">https://github.com/puppeteer/puppeteer/issues/8836</a>). Also, the term "incognito" is not applicable to other browsers. To migrate, check the <ahref="/next/api/puppeteer.browser.defaultbrowsercontext">default browser context</a> instead: in Chrome all non-default contexts are incognito, and the default context might be incognito if you provide the <code>--incognito</code> argument when launching the browser.</p></td></tr><tr><td><spanid="newpage"><ahref="/next/api/puppeteer.browsercontext.newpage">newPage()</a></span></td><td></td><td><p>Creates a new <ahref="/next/api/puppeteer.page">page</a> in this <ahref="/next/api/puppeteer.browsercontext">browser context</a>.</p></td></tr><tr><td><spanid="overridepermissions"><ahref="/next/api/puppeteer.browsercontext.overridepermissions">overridePermissions(origin, permissions)</a></span></td><td></td><td><p>Grants this <ahref="/next/api/puppeteer.browsercontext">browser context</a> the given <code>permissions</code> within the given <code>origin</code>.</p></td></tr><tr><td><spanid="pages"><ahref="/next/api/puppeteer.browsercontext.pages">pages()</a></span></td><td></td><td><p>Gets a list of all open <ahref="/next/api/puppeteer.page">pages</a> inside this <ahref="/next/api/puppeteer.browsercontext">browser context</a>.</p><p><strong>Remarks:</strong></p><p>Non-visible <ahref="/next/api/puppeteer.page">pages</a>, such as <code>"background_page"</code>, will not be listed here. You can find them using <ahref="/next/api/puppeteer.target.page">Target.page()</a>.</p></td></tr><tr><td><spanid="targets"><ahref="/next/api/puppeteer.browsercontext.targets">targets()</a></span></td><td></td><td><p>Gets all active <ahref="/next/api/puppeteer.target">targets</a> inside this <ahref="/next/api/puppeteer.browsercontext">browser context</a>.</p></td></tr><tr><td><spanid="waitfortarget"><ahref="/next/api/puppeteer.browsercontext.waitfortarget">waitForTarget(predicate, options)</a></span></td><td></td><td><p>Waits until a <ahref="/next/api/puppeteer.target">target</a> matching the given <code>predicate</code> appears and returns it.</p><p>This will look all open <ahref="/next/api/puppeteer.browsercontext">browse