mokr.browser.target
Module Contents
Classes
Representative of a remote target. |
Attributes
- mokr.browser.target.KINDS
- class mokr.browser.target.Target(browser: mokr.browser.Browser, target_info: dict, browser_context: mokr.browser.context.BrowserContext, session_factory: Callable, ignore_https_errors: bool, default_viewport: dict | None, screenshot_task_queue: list, loop: asyncio.AbstractEventLoop, proxy_credentials: dict | None = None, user_agent_data: dict[str, str] | None = None)
Representative of a remote target. Targets are a somewhat obscure concept, they can be a browser, frame, page, worker, or more. For the purposes of this package, only browser, pages, and workers are tracked explicitly. Full list of target types can be found at
devtools_agent_host_impl.ccat https://source.chromium.org/chromium/chromium/src/.- Parameters:
browser (Browser) – Parent
mokr.browser.Browser.target_info (dict) – The “targetInfo” in the event emitted that triggered this object’s initialisation.
browser_context (BrowserContext) – The
mokr.browser.BrowserContextthat this spawned from.session_factory (Callable) – Callable that creates a new
mokr.connection.DevtoolsConnectionfor this target.ignore_https_errors (bool) – Whether network security errors should be ignored or not. Inherited from parent
mokr.browser.Browser.default_viewport (dict | None) – Default viewport configuration. Inherited from parent
mokr.browser.Browser.screenshot_task_queue (list) – The screenshot task queue, empty by default. Inherited from parent
mokr.browser.Browser.loop (asyncio.AbstractEventLoop) – The
asyncioloop that is tracked under themokr.browser.Browser’smokr.connection.Connection.proxy_credentials – (dict | None, optional): Dictionary with proxy credentials keyed as “username” and “password”. Credentials should be for the proxy the browser process is bound to. Inherited from parent
mokr.browser.Browser.user_agent_data (dict[str, str] | None, optional) – A dictionary containing the user agent and an indicator to whether it was the original or an override.
- property url: str
Get url of this target.
- property kind: KINDS
Get type of this target. Type may be on of “page”, “background_page”, “service_worker”, “browser”, or “other”.
- property browser: mokr.browser.Browser
The
mokr.browser.Browserthat owns themokr.browser.BrowserContextthat this target was initialised from.
- property browser_context: mokr.browser.context.BrowserContext
mokr.browser.BrowserContextthis target was initialised from.
- async create_devtools_connection() mokr.connection.DevtoolsConnection
Initialise the
mokr.connection.DevtoolsConnectionthat will be bound to thisTarget.- Returns:
The new
mokr.connection.DevtoolsConnection.- Return type:
- async page() mokr.browser.page.Page | None
Get the
mokr.browser.Pageobject attached to thisTarget. Only applicable ifTarget.kindis “page” or “background_page”.- Returns:
Associated
mokr.browser.Page, if any.- Return type:
Page | None