mokr.connection.devtools

Attributes

LOGGER

Classes

DevtoolsConnection

Create new CDP (Chrome Devtools Protocol) session.

Module Contents

mokr.connection.devtools.LOGGER
class mokr.connection.devtools.DevtoolsConnection(connection: mokr.connection.connection.Connection | DevtoolsConnection, target_type: str, session_id: str, loop: asyncio.AbstractEventLoop)

Bases: pyee.EventEmitter, mokr.connection.base.RemoteConnection

Create new CDP (Chrome Devtools Protocol) session.

Most functionality is controlled by calling CDP methods or handling CDP events. Read more about these at: https://chromedevtools.github.io/devtools-protocol/

Parameters:
  • connection (Connection | DevtoolsConnection) – Parent remote connection to use.

  • target_type (str) – Type of target this connection is for.

  • session_id (str) – Unique session identifier.

  • loop (asyncio.AbstractEventLoop) – Running asyncio loop.

send(method: str, params: dict = None) Awaitable[dict]

Send a message to the remote connection.

Parameters:
  • method (str) – Method to run.

  • params (dict, optional) – Arguments for method, if any. Defaults to None.

Raises:

NetworkError – Raised if connection is closed.

Returns:

Remote response as dictionary.

Return type:

Awaitable[dict]

async detach() None

Detach session from it’s target. Once detached, it is invalid and cannot receive or send messages.

Raises:

NetworkError – Raised if remote connection is already closed.