Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

Index

Methods

addListener

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

browser

  • The browser this browser context belongs to.

    Returns Browser

clearPermissionOverrides

  • clearPermissionOverrides(): Promise<void>
  • Clears all permission overrides for the browser context.

    Returns Promise<void>

close

  • close(): Promise<void>
  • Closes the browser context. All the targets that belong to the browser context will be closed.

    Returns Promise<void>

emit

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

    • event: EventType
    • Optional eventData: any

    Returns boolean

isIncognito

  • isIncognito(): boolean
  • Returns whether BrowserContext is incognito. The default browser context is the only non-incognito browser context.

    Returns boolean

listenerCount

  • listenerCount(event: string): number
  • Parameters

    • event: string

    Returns number

newPage

  • newPage(): Promise<Page>
  • Creates a new page in the browser context.

    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: "targetchanged" | "targetcreated" | "targetdestroyed"

    Parameters

    Returns BrowserContext

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: "targetchanged" | "targetcreated" | "targetdestroyed"

    Parameters

    Returns BrowserContext

overridePermissions

  • overridePermissions(origin: string, permissions: Permission[]): Promise<void>
  • Parameters

    • origin: string

      The origin to grant permissions to, e.g. "https://example.com".

    • permissions: Permission[]

      An array of permissions to grant. All permissions that are not listed here will be automatically denied.

    Returns Promise<void>

pages

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

    Returns Promise<Page[]>

removeAllListeners

removeListener

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

targets

  • An array of all active targets inside the browser context.

    Returns Target[]

waitForTarget

Generated using TypeDoc