<titledata-rh="true">Browser 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/api/puppeteer.browser"><metadata-rh="true"property="og:locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docsearch:counter"content="2"><metadata-rh="true"property="og:title"content="Browser class | Puppeteer"><metadata-rh="true"name="description"content="Browser represents a browser instance that is either:"><metadata-rh="true"property="og:description"content="Browser represents a browser instance that is either:"><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/api/puppeteer.browser"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/api/puppeteer.browser"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/api/puppeteer.browser"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="/api/puppeteer.browser">Browser</a> represents a browser instance that is either:</p>
<ul>
<li>connected to via <ahref="/api/puppeteer.puppeteer.connect">Puppeteer.connect()</a> or - launched by <ahref="/api/puppeteer.puppeteernode.launch">PuppeteerNode.launch()</a>.</li>
</ul>
<p><ahref="/api/puppeteer.browser">Browser</a><ahref="/api/puppeteer.eventemitter">emits</a> various events which are documented in the <ahref="/api/puppeteer.browserevent">BrowserEvent</a> enum.</p>
<h4class="anchor anchorWithStickyNavbar_LWe7"id="signature">Signature:<ahref="#signature"class="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"></a></h4>
<h2class="anchor anchorWithStickyNavbar_LWe7"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>Browser</code> class.</p>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="example-1">Example 1<ahref="#example-1"class="hash-link"aria-label="Direct link to Example 1"title="Direct link to Example 1"></a></h2>
<p>Using a <ahref="/api/puppeteer.browser">Browser</a> to create a <ahref="/api/puppeteer.page">Page</a>:</p>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="example-2">Example 2<ahref="#example-2"class="hash-link"aria-label="Direct link to Example 2"title="Direct link to Example 2"></a></h2>
<p>Disconnecting from and reconnecting to a <ahref="/api/puppeteer.browser">Browser</a>:</p>
<h2class="anchor anchorWithStickyNavbar_LWe7"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><p>connected</p></td><td><p><code>readonly</code></p></td><td><p>boolean</p></td><td><p>Whether Puppeteer is connected to this <ahref="/api/puppeteer.browser">browser</a>.</p></td></tr><tr><td><p>debugInfo</p></td><td><p><code>readonly</code></p></td><td><p><ahref="/api/puppeteer.debuginfo">DebugInfo</a></p></td><td><p>Get debug information from Puppeteer.</p></td></tr></tbody></table>
<h2class="anchor anchorWithStickyNavbar_LWe7"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><p><ahref="/api/puppeteer.browser.browsercontexts">browserContexts()</a></p></td><td></td><td><p>Gets a list of open <ahref="/api/puppeteer.browsercontext">browser contexts</a>.</p><p>In a newly-created <ahref="/api/puppeteer.browser">browser</a>, this will return a single instance of <ahref="/api/puppeteer.browsercontext">BrowserContext</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.close">close()</a></p></td><td></td><td><p>Closes this <ahref="/api/puppeteer.browser">browser</a> and all associated <ahref="/api/puppeteer.page">pages</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.createbrowsercontext">createBrowserContext(options)</a></p></td><td></td><td><p>Creates a new <ahref="/api/puppeteer.browsercontext">browser context</a>.</p><p>This won't share cookies/cache with other <ahref="/api/puppeteer.browsercontext">browser contexts</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.defaultbrowsercontext">defaultBrowserContext()</a></p></td><td></td><td><p>Gets the default <ahref="/api/puppeteer.browsercontext">browser context</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.disconnect">disconnect()</a></p></td><td></td><td><p>Disconnects Puppeteer from this <ahref="/api/puppeteer.browser">browser</a>, but leaves the process running.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.isconnected">isConnected()</a></p></td><td></td><td><p>Whether Puppeteer is connected to this <ahref="/api/puppeteer.browser">browser</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.newpage">newPage()</a></p></td><td></td><td><p>Creates a new <ahref="/api/puppeteer.page">page</a> in the <ahref="/api/puppeteer.browser.defaultbrowsercontext">default browser context</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.pages">pages()</a></p></td><td></td><td><p>Gets a list of all open <ahref="/api/puppeteer.page">pages</a> inside this <ahref="/api/puppeteer.browser">Browser</a>.</p><p>If there ar multiple <ahref="/api/puppeteer.browsercontext">browser contexts</a>, this returns all <ahref="/api/puppeteer.page">pages</a> in all <ahref="/api/puppeteer.browsercontext">browser contexts</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.process">process()</a></p></td><td></td><td><p>Gets the associated <ahref="https://nodejs.org/api/child_process.html#class-childprocess"target="_blank"rel="noopener noreferrer">ChildProcess</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.target">target()</a></p></td><td></td><td><p>Gets the <ahref="/api/puppeteer.target">target</a> associated with the <ahref="/api/puppeteer.browser.defaultbrowsercontext">default browser context</a>).</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.targets">targets()</a></p></td><td></td><td><p>Gets all active <ahref="/api/puppeteer.target">targets</a>.</p><p>In case of multiple <ahref="/api/puppeteer.browsercontext">browser contexts</a>, this returns all <ahref="/api/puppeteer.target">targets</a> in all <ahref="/api/puppeteer.browsercontext">browser contexts</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.useragent">userAgent()</a></p></td><td></td><td><p>Gets this <ahref="/api/puppeteer.browser">browser's</a> original user agent.</p><p><ahref="/api/puppeteer.page">Pages</a> can override the user agent with <ahref="/api/puppeteer.page.setuseragent">Page.setUserAgent()</a>.</p></td></tr><tr><td><p><ahref="/api/puppeteer.browser.version">version()</a></p></td><td></td><td><p>Gets a string representing this <ahref="/api/puppeteer.browser">browser's</a> name and version.</p><p>For headless browser, this is similar to <code>"HeadlessChrome/61.0.3153.0"</code>. For non-headless or new-headless, this is similar to <code>"Chrome/61.0.3153.0"</code>. For Firefox, it is similar to <code>"Firefox/116.0a1"</code>.</p><p>The format of <ahref="/api/puppeteer.browser.version">Browser.ve