Browser class

A Browser is created when Puppeteer connects to a Chromium instance, either through puppeteer.launch or puppeteer.connect.

An example of using a Browser to create a Page:

void main() async {
  var browser = await puppeteer.launch();
  var page = await browser.newPage();
  await page.goto('https://example.com');
  await browser.close();
}

Properties

browser BrowserApi
final
browserContexts List<BrowserContext>
Returns a list of all open browser contexts. In a newly created browser, this will return a single instance of BrowserContext.
no setter
connection → Connection
final
defaultBrowserContext BrowserContext
Returns the default browser context. The default browser context can not be closed.
no setter
defaultViewport DeviceViewport?
final
disconnected Future<void>
no setter
hashCode int
The hash code for this object.
no setterinherited
ignoreHttpsErrors bool
final
isConnected bool
no setter
onTargetChanged Stream<Target>
Emitted when the url of a target changes.
no setter
onTargetCreated Stream<Target>
Emitted when a target is created, for example when a new page is opened by window.open or Browser.newPage.
no setter
onTargetDestroyed Stream<Target>
Emitted when a target is destroyed, for example when a page is closed.
no setter
onTargetDiscovered Stream<TargetInfo>
no setter
pages Future<List<Page>>
Future which resolves to a list of all open pages. Non visible pages, such as "background_page", will not be listed here. You can find them using Target.page.
no setter
plugins Iterable<Plugin>
no setter
process Process?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
systemInfo SystemInfoApi
final
target Target
A target associated with the browser.
no setter
targets List<Target>
A list of all active targets inside the Browser. In case of multiple browser contexts, the method will return an array with all the targets in all browser contexts.
no setter
userAgent Future<String>
Future which resolves to the browser's original user agent.
no setter
version Future<String>
For headless Chrome, this is similar to HeadlessChrome/61.0.3153.0. For non-headless, this is similar to Chrome/61.0.3153.0.
no setter
wsEndpoint String
no setter

Methods

close() Future<void>
Closes Chromium and all of its pages (if any were opened). The Browser object itself is considered to be disposed and cannot be used anymore.
createIncognitoBrowserContext() Future<BrowserContext>
Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.
disconnect() → void
newPage() Future<Page>
Future which resolves to a new Page object. The Page is created in a default browser context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
waitForTarget(bool predicate(Target), {Duration? timeout}) Future<Target>
This searches for a target in all browser contexts.

Operators

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