mokr.browser.context
Attributes
Classes
Browser context within the browser process. Contexts are independent |
Module Contents
- mokr.browser.context.LOGGER
- class mokr.browser.context.BrowserContext(browser: mokr.browser.Browser, context_id: str | None)
Bases:
pyee.EventEmitterBrowser context within the browser process. Contexts are independent of one another, not sharing storage. Contexts beyond the default context that
mokr.browser.Browserstarts with will be incognito.- Parameters:
browser (Browser) – Parent
mokr.browser.Browserobject from which the context was spawned.context_id (str | None) – The context identifier (may be None).
- property incognito: bool
True if the browser context is incognito, otherwise False. Only default context spawned when the
mokr.browser.Browserobject is spawned is not incognito.
- property browser: mokr.browser.Browser
The
mokr.browser.Browserobject this context is attached to.
- targets() list[mokr.browser.target.Target]
A list of all `mokr.browser.Target`s in this context.
- Returns:
All initialised targets within this context.
- Return type:
list[Target]
- async pages() list[mokr.browser.page.Page]
A list of all `mokr.browser.Page`s in this context.
- Returns:
All pages within this context.
- Return type:
list[Page]
- async first_page() mokr.browser.page.Page
Return the first page in
BrowserContext.pages. If no pages active, returns None.- Returns:
First active page in this context, if any.
- Return type:
Page | None
- async new_page() mokr.browser.page.Page
Spawn a new page.
- Returns:
A new
mokr.browser.Pageat “about:blank”.- Return type:
- async close() None
Close the context. Can only be done on incognito contexts.
- Raises:
BrowserError – Raised if called from the default context.