Skip to content

limelight.scene

Scene

A page object for a single screen of a demo.

This class pairs a route with the assertions that prove the screen has loaded. A subclass sets the route and overrides expect_ready().

The protected helpers are the vocabulary an actor is written in. Each one performs an action through the demo and then holds, so a narrated run shows the drawn pointer land before the next step begins and a silent run pays nothing for the hold. A scene calls them rather than a Playwright locator method, because a bare click moves the real mouse without moving the drawn one.

class OrderScene(Scene):
    route = 'sales:order:page:list'

    def expect_ready(self) -> None:
        expect(self.search_field).to_be_visible()

    def search(self, text: str) -> None:
        self._teach_focus(self.search_field, headline='Search', label='Search')

        self._fill(self.search_field, text)

The constructor for the Scene class.

Parameters:

  • demo (Demo) –

    The demo that drives the browser for this scene.

Source code in limelight/scene.py
def __init__(self, demo: Demo) -> None:
    """
    The constructor for the Scene class.

    :param demo: The demo that drives the browser for this scene.
    """

    self.demo = demo

route = '' class-attribute instance-attribute

demo = demo instance-attribute

expect_ready

A method that waits until the scene has finished loading.

The base implementation does nothing, so a scene that needs to settle before the next step overrides this with its own assertions.

Source code in limelight/scene.py
def expect_ready(self) -> None:
    """
    A method that waits until the scene has finished loading.

    The base implementation does nothing, so a scene that needs to settle
    before the next step overrides this with its own assertions.
    """

open

A method that navigates to the scene route and waits for it to be ready.

Parameters:

  • query (Mapping[str, object] | None, default: None ) –

    The query string parameters appended to the URL, or None for none.

  • url_kwargs (object, default: {} ) –

    The arguments used to reverse the route into a URL.

Returns:

  • Self –

    The scene itself, so calls can be chained.

Raises:

  • ValueError –

    If the route has not been set on the subclass.

Source code in limelight/scene.py
def open(
    self,
    *,
    query: Mapping[str, object] | None = None,
    **url_kwargs: object,
) -> Self:
    """
    A method that navigates to the scene route and waits for it to be ready.

    :param query: The query string parameters appended to the URL, or None for none.
    :param url_kwargs: The arguments used to reverse the route into a URL.
    :return: The scene itself, so calls can be chained.
    :raises ValueError: If the route has not been set on the subclass.
    """

    if not self.route:
        message = f'{type(self).__name__}.route must be set before open()'
        raise ValueError(message)

    self.demo.goto(self.route, query=query, **url_kwargs)
    self.expect_ready()

    return self