Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

Index

Methods

addListener

  • addListener(event: EventType, handler: Handler<any>): EventEmitter

browserContexts

  • Returns an array of all open browser contexts. In a newly created browser, this will return a single instance of BrowserContext.

    Returns BrowserContext[]

close

  • close(): Promise<void>
  • Closes browser with all the pages (if any were opened). The browser object itself is considered to be disposed and can not be used anymore.

    Returns Promise<void>

createIncognitoBrowserContext

  • Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.

    Returns Promise<BrowserContext>

defaultBrowserContext

  • Returns the default browser context. The default browser context can not be closed.

    Returns BrowserContext

disconnect

  • disconnect(): void
  • Disconnects Puppeteer from the browser, but leaves the Chromium process running. After calling disconnect, the browser object is considered disposed and cannot be used anymore.

    Returns void

emit

  • emit(event: EventType, eventData?: any): boolean
  • Parameters

    • event: EventType
    • Optional eventData: any

    Returns boolean

isConnected

  • isConnected(): boolean
  • Indicates that the browser is connected.

    Returns boolean

listenerCount

  • listenerCount(event: string): number
  • Parameters

    • event: string

    Returns number

newPage

  • newPage(): Promise<Page>
  • Promise which resolves to a new Page object.

    Returns Promise<Page>

off

  • off(event: EventType, handler: Handler<any>): EventEmitter
  • Parameters

    • event: EventType
    • handler: Handler<any>

    Returns EventEmitter

on

  • Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

    Type parameters

    • K: "disconnected" | "targetchanged" | "targetcreated" | "targetdestroyed"

    Parameters

    Returns Browser

once

  • Adds a one time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

    Type parameters

    • K: "disconnected" | "targetchanged" | "targetcreated" | "targetdestroyed"

    Parameters

    Returns Browser

pages

  • pages(): Promise<Page[]>
  • Promise which resolves to an array of all open pages.

    Returns Promise<Page[]>

process

  • process(): ChildProcess
  • Spawned browser process. Returns null if the browser instance was created with puppeteer.connect method

    Returns ChildProcess

removeAllListeners

removeListener

  • removeListener(event: EventType, handler: Handler<any>): EventEmitter

target

  • A target associated with the browser.

    Returns Target

targets

  • targets(): Promise<Target[]>
  • Promise which resolves to an array of all active targets.

    Returns Promise<Target[]>

userAgent

  • userAgent(): Promise<string>
  • Promise which resolves to the browser's original user agent. NOTE Pages can override browser user agent with page.setUserAgent.

    Returns Promise<string>

version

  • version(): Promise<string>
  • For headless Chromium, this is similar to HeadlessChrome/61.0.3153.0. For non-headless, this is similar to Chrome/61.0.3153.0.

    Returns Promise<string>

waitForTarget

wsEndpoint

  • wsEndpoint(): string
  • Browser websocket endpoint which can be used as an argument to puppeteer.connect. The format is ws://${host}:${port}/devtools/browser/

    Returns string

Generated using TypeDoc