mokr.browser.worker

Attributes

LOGGER

Classes

WebWorker

Represents a web worker on the page. This object is created and

Module Contents

mokr.browser.worker.LOGGER
class mokr.browser.worker.WebWorker(client: mokr.connection.DevtoolsConnection, url: str, console_api_callback: Callable, exception_thrown: Callable)

Bases: pyee.EventEmitter

Represents a web worker on the page. This object is created and destroyed by it’s parent mokr.browser.Page.

Parameters:
  • client (DevtoolsConnection) – A mokr.connection.DevtoolsConnection spawned by the parent mokr.browser.Page.

  • url (str) – The “url” present in the triggering event’s “targetInfo”.

  • console_api_callback (Callable) – Callback to run when the console is called, if no listener’s are present for this on the mokr.browser.Page, will delete the handle due to given default callback from parent Page.

  • exception_thrown (Callable) – Callback to run if exception occurs.

console_api_callback
property url: str

URL associated with the event that triggered this worker.

async execution_context() mokr.execution.context.ExecutionContext

Return the newly created mokr.execution.ExecutionContext.

Returns:

mokr.execution.ExecutionContext.

Return type:

ExecutionContext

async evaluate(page_function: str, *args: Any) dict | None

Execute a JavaScript function with given arguments. Run this WebWorker’s mokr.execution.ExecutionContext.evaluate.

Parameters:

page_function (str) – JavaScript function to run.

Raises:
Returns:

The decoded object (dict) via

mokr.execution.JavascriptHandle.json or None if a known error occurs decoding it.

Return type:

dict | None

async evaluate_handle(page_function: str, *args: Any) mokr.execution.context.JavascriptHandle

Execute a JavaScript function with given arguments. Run this WebWorker’s mokr.execution.ExecutionContext.evaluate_handle.

Parameters:

page_function (str) – JavaScript function to run.

Returns:

mokr.execution.JavascriptHandle.

Return type:

JavascriptHandle