mokr.frame.wait

Module Contents

Classes

WaitTask

Class used to monitor a remote frame for events to occur within

Attributes

LOGGER

mokr.frame.wait.LOGGER
class mokr.frame.wait.WaitTask(frame: mokr.frame.frame.Frame, predicate_body: str, title: str, polling: Literal[raf, mutation] | int | float, timeout: float, loop: asyncio.AbstractEventLoop, *args: Any)

Class used to monitor a remote frame for events to occur within a given timer interval.

Parameters:
  • frame (Frame) – mokr.frame.Frame that spawned this WaitTask.

  • predicate_body (str) – JavaScript function to return from.

  • title (str) – Title to be used to contextualise error, if any.

  • polling (Literal["raf", "mutation"] | int | float) – Polling type; if set to “raf”, executes continously in “requestAnimationFrame”, else if set to “mutation” executes only on DOM mutations. Defaults to “raf”.

  • timeout (float) – Time in milliseconds to wait.

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

Raises:

ValueError – Raised if polling_type not “raf” or “mutation”.

terminate(error: Exception) None

Finish the task, if the promise is still not done, set the result with the given error, then remove this task from the parent mokr.frame.Frame.

Parameters:

error (Exception) – Error to raise if watched promise isn’t done.

async rerun() None

Start polling for the expected condition.

Raises:

PageError – Raised if no mokr.execution.ExecutionContext attached to the parent mokr.frame.Frame.