mokr.browser.worker =================== .. py:module:: mokr.browser.worker Attributes ---------- .. autoapisummary:: mokr.browser.worker.LOGGER Classes ------- .. autoapisummary:: mokr.browser.worker.WebWorker Module Contents --------------- .. py:data:: LOGGER .. py:class:: WebWorker(client: mokr.connection.DevtoolsConnection, url: str, console_api_callback: Callable, exception_thrown: Callable) Bases: :py:obj:`pyee.EventEmitter` Represents a web worker on the page. This object is created and destroyed by it's parent `mokr.browser.Page`. :param client: A `mokr.connection.DevtoolsConnection` spawned by the parent `mokr.browser.Page`. :type client: DevtoolsConnection :param url: The "url" present in the triggering event's "targetInfo". :type url: str :param console_api_callback: 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`. :type console_api_callback: Callable :param exception_thrown: Callback to run if exception occurs. :type exception_thrown: Callable .. py:attribute:: console_api_callback .. py:property:: url :type: str URL associated with the event that triggered this worker. .. py:method:: execution_context() -> mokr.execution.context.ExecutionContext :async: Return the newly created `mokr.execution.ExecutionContext`. :returns: `mokr.execution.ExecutionContext`. :rtype: ExecutionContext .. py:method:: evaluate(page_function: str, *args: Any) -> dict | None :async: Execute a JavaScript function with given arguments. Run this `WebWorker`'s `mokr.execution.ExecutionContext.evaluate`. :param page_function: JavaScript function to run. :type page_function: str :raises mokr.exceptions.NetworkError: :raises either evaluating the function or requesting the resulting object.: :returns: The decoded object (dict) via `mokr.execution.JavascriptHandle.json` or None if a known error occurs decoding it. :rtype: dict | None .. py:method:: evaluate_handle(page_function: str, *args: Any) -> mokr.execution.context.JavascriptHandle :async: Execute a JavaScript function with given arguments. Run this `WebWorker`'s `mokr.execution.ExecutionContext.evaluate_handle`. :param page_function: JavaScript function to run. :type page_function: str :returns: `mokr.execution.JavascriptHandle`. :rtype: JavascriptHandle