BrowserContexts provide a way to operate multiple independent sessions, with separate pages, cache, and cookies. A default BrowserContext is created when a Browser is launched.
The Browser type is used to create a new BrowserContext.
If a page opens another page, e.g. with a window.open call, the popup will belong to the parent page's BrowserContext.
Method | Description |
---|---|
BrowserContext.browser() | Returns the Browser instance that this BrowserContext belongs to. |
BrowserContext.clearCookies() | Clear the BrowserContext's cookies. |
BrowserContext.clearPermissions() | Clears all permission overrides for the BrowserContext. |
BrowserContext.close() | Close the BrowserContext and all its pages. |
BrowserContext.grantPermissions(permissions[, options]) | Grants specified permissions to the BrowserContext. |
BrowserContext.newPage() | Uses the BrowserContext to create a new Page and returns it. |
BrowserContext.pages() | Returns a list of pages that belongs to the BrowserContext. |
BrowserContext.setDefaultNavigationTimeout(timeout) | Sets the default navigation timeout in milliseconds. |
BrowserContext.setDefaultTimeout(timeout) | Sets the default maximum timeout for all methods accepting a timeout option in milliseconds. |
BrowserContext.setGeolocation(geolocation) | Sets the BrowserContext's geolocation. |
BrowserContext.setOffline(offline) | Toggles the BrowserContext's connectivity on/off. |
BrowserContext.waitForEvent(event[, optionsOrPredicate]) | Waits for the event to fire and passes its value into the predicate function. |