mokr.waiters ============ .. py:module:: mokr.waiters Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/mokr/waiters/event/index /autoapi/mokr/waiters/navigation/index Classes ------- .. autoapisummary:: mokr.waiters.EventWaiter mokr.waiters.NavigationWaiter Package Contents ---------------- .. py:class:: EventWaiter(emitter: pyee.EventEmitter, event_name: str, predicate: Callable, timeout: float, loop: asyncio.AbstractEventLoop) Class to wait for an event to be emitted and then run a callback `predicate` when it is. If the callback resolves to a truthy value, the timer is cancelled. Otherwise, a `mokr.exceptions.MokrTimeoutError` is raised. :param emitter: Emitter to listen to. :type emitter: EventEmitter :param event_name: Event name to listen for. :type event_name: str :param predicate: Callback to run when event is emitted. :type predicate: Callable :param timeout: Time in milliseconds to wait for event. :type timeout: float :param loop: Running asyncio loop. :type loop: asyncio.AbstractEventLoop .. py:attribute:: listener :value: None .. py:attribute:: promise .. py:method:: wait() -> Awaitable Wait for the target event to be emitted and then run the target predicate when it is. If that resolves to a truthy value, cancel the timer, otherwise, raise a `mokr.exceptions.MokrTimeoutError` exception. :returns: Awaitable that yields result of the target callback. :rtype: Awaitable .. py:class:: NavigationWaiter(frame_manager: mokr.frame.FrameManager, frame: mokr.frame.Frame, timeout: int, wait_until: list[mokr.constants.LIFECYCLE_EVENTS] | mokr.constants.LIFECYCLE_EVENTS) Class to listen to a `mokr.frame.FrameManager` for specific navigation event(s) (`LIFECYCLE_EVENTS`) in the target `mokr.frame.Frame` for up to a given `timeout`. If all events not seen before timeout, raises a `MokrTimeoutError` exception. :param frame_manager: The `mokr.frame.FrameManager` to watch for lifecycle events. :type frame_manager: FrameManager :param frame: The `mokr.frame.Frame` that seen events count toward. :type frame: Frame :param timeout: Tiem in milliseconds to wait for event. :type timeout: int :param wait_until: Either a list of events or a single event to wait for. :type wait_until: list[LIFECYCLE_EVENTS] | LIFECYCLE_EVENTS .. py:method:: navigation_promise() -> Any Return the promise so errors can be handled externally. :returns: Navigation promise. :rtype: Any .. py:method:: cancel() -> None Stop this waiter, raise no errors.