BrowserContext class

BrowserContexts provide a way to operate multiple independent browser sessions. When a browser is launched, it has a single BrowserContext used by default. The method Browser.newPage creates a page in the default browser context.

If a page opens another page, e.g. with a window.open call, the popup will belong to the parent page's browser context.

Puppeteer allows creation of "incognito" browser contexts with Browser.createIncognitoBrowserContext method. "Incognito" browser contexts don't write any browsing data to disk.

Constructors

BrowserContext(Connection? connection, Browser browser, BrowserContextID? id)

Properties

browser Browser
The browser this browser context belongs to.
final
connection → Connection?
final
hashCode int
The hash code for this object.
no setterinherited
id BrowserContextID?
final
isIncognito bool
Returns whether BrowserContext is incognito. The default browser context is the only non-incognito browser context.
no setter
onTargetChanged Stream<Target>
Emitted when the url of a target inside the browser context changes.
no setter
onTargetCreated Stream<Target>
Emitted when a new target is created inside the browser context, for example when a new page is opened by window.open or browserContext.newPage.
no setter
onTargetDestroyed Stream<Target>
Emitted when a target inside the browser context is destroyed, for example when a page is closed.
no setter
pages Future<List<Page>>
An array of all pages inside the browser context.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
targets List<Target>
An array of all active targets inside the browser context.
no setter

Methods

clearPermissionOverrides() Future<void>
Clears all permission overrides for the browser context.
close() Future<void>
Closes the browser context. All the targets that belong to the browser context will be closed.
newPage() Future<Page>
Creates a new page in the browser context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overridePermissions(String origin, List<PermissionType> permissions) Future<void>
origin
toString() String
A string representation of this object.
inherited
waitForTarget(bool predicate(Target), {Duration? timeout}) Future<Target>
This searches for a target in this specific browser context.

Operators

operator ==(Object other) bool
The equality operator.
inherited