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