🤖 I have created a release *beep* *boop* --- <details><summary>browsers: 2.2.2</summary> ## [2.2.2](https://github.com/puppeteer/puppeteer/compare/browsers-v2.2.1...browsers-v2.2.2) (2024-04-15) ### Bug Fixes * remove NetworkServiceInProcess2 set by default ([#12261](https://github.com/puppeteer/puppeteer/issues/12261)) ([ff4f70f
](ff4f70f4ae
)), closes [#12257](https://github.com/puppeteer/puppeteer/issues/12257) </details> <details><summary>puppeteer: 22.6.5</summary> ## [22.6.5](https://github.com/puppeteer/puppeteer/compare/puppeteer-v22.6.4...puppeteer-v22.6.5) (2024-04-15) ### Miscellaneous Chores * **puppeteer:** Synchronize puppeteer versions ### Dependencies * The following workspace dependencies were updated * dependencies * puppeteer-core bumped from 22.6.4 to 22.6.5 * @puppeteer/browsers bumped from 2.2.1 to 2.2.2 </details> <details><summary>puppeteer-core: 22.6.5</summary> ## [22.6.5](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v22.6.4...puppeteer-core-v22.6.5) (2024-04-15) ### Bug Fixes * remove NetworkServiceInProcess2 set by default ([#12261](https://github.com/puppeteer/puppeteer/issues/12261)) ([ff4f70f
](ff4f70f4ae
)), closes [#12257](https://github.com/puppeteer/puppeteer/issues/12257) * use setImmediate to reduce flakiness when processing events ([#12264](https://github.com/puppeteer/puppeteer/issues/12264)) ([73403b3
](73403b323e
)) ### Dependencies * The following workspace dependencies were updated * dependencies * @puppeteer/browsers bumped from 2.2.1 to 2.2.2 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
5.2 KiB
sidebar_label |
---|
BrowserContext |
BrowserContext class
BrowserContext represents individual user contexts within a browser.
When a browser is launched, it has a single browser context by default. Others can be created using Browser.createBrowserContext(). Each context has isolated storage (cookies/localStorage/etc.)
BrowserContext emits various events which are documented in the BrowserContextEvent enum.
If a page opens another page, e.g. using window.open
, the popup will belong to the parent page's browser context.
Signature:
export declare abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
Extends: EventEmitter<BrowserContextEvents>
Remarks
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the BrowserContext
class.
Example
Creating a new browser context:
// Create a new browser context
const context = await browser.createBrowserContext();
// Create a new page inside context.
const page = await context.newPage();
// ... do stuff with page ...
await page.goto('https://example.com');
// Dispose context once it's no longer needed.
await context.close();
Properties
Property |
Modifiers |
Type |
Description |
---|---|---|---|
closed |
|
boolean |
Whether this browser context is closed. |
id |
|
string | undefined |
Identifier for this browser context. |
Methods
Method |
Modifiers |
Description |
---|---|---|
Gets the browser associated with this browser context. | ||
Clears all permission overrides for this browser context. | ||
Closes this browser context and all associated pages. | ||
|
Whether this browser context is incognito. In Chrome, the default browser context is the only non-incognito browser context. Deprecated: In Chrome, the default browser context can also be "incognito" if configured via the arguments and in such cases this getter returns wrong results (see https://github.com/puppeteer/puppeteer/issues/8836). Also, the term "incognito" is not applicable to other browsers. To migrate, check the default browser context instead: in Chrome all non-default contexts are incognito, and the default context might be incognito if you provide the | |
Creates a new page in this browser context. | ||
Grants this browser context the given | ||
Gets a list of all open pages inside this browser context. | ||
Gets all active targets inside this browser context. | ||
Waits until a target matching the given This will look all open browser contexts. |