mokr.browser.worker
Module Contents
Classes
Represents a web worker on the page. This object is created and |
Attributes
- mokr.browser.worker.LOGGER
- class mokr.browser.worker.WebWorker(client: mokr.connection.DevtoolsConnection, url: str, console_api_callback: Callable, exception_thrown: Callable)
Bases:
pyee.EventEmitterRepresents 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.DevtoolsConnectionspawned by the parentmokr.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 parentPage.exception_thrown (Callable) – Callback to run if exception occurs.
- 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:
- async evaluate(page_function: str, *args: Any) dict | None
Execute a JavaScript function with given arguments. Run this
WebWorker’smokr.execution.ExecutionContext.evaluate.- Parameters:
page_function (str) – JavaScript function to run.
- Raises:
either evaluating the function or requesting the resulting object. –
- Returns:
- The decoded object (dict) via
mokr.execution.JavascriptHandle.jsonor 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’smokr.execution.ExecutionContext.evaluate_handle.- Parameters:
page_function (str) – JavaScript function to run.
- Returns:
mokr.execution.JavascriptHandle.- Return type: