02.03.06 — drive_page#
Source file:
src/ocarina/opinionated/dsl/drive_page.py
Code#
def drive_page(
first: ActionSuccess[TPOM], *rest: ActionSuccess[TPOM]
) -> ChainRunner[TPOM]:
return chain_actions(first, *rest)Literally chain_actions.
Why this alias?#
1. Semantics: “I’m taking control of a page”#
Holy Book quote (“First scenarios”):
drive_pageexpresses the fact that you are taking control of one page. Any transition becomes explicit through the opening of a newdrive_page.
return [
drive_page(
act(on_homepage, open_homepage)...,
act(on_homepage, verify_homepage)...,
act(on_homepage, click_cta)...,
), # ⬅ closing control of the homepage
drive_page( # ⬅ opening control of the next page
act(on_target_page, verify_target_page)...,
),
]2. Discipline#
Mixing acts from two different POMs inside one drive_page is a mypy error (see 02-action-chain-states.md, “narrowing via act()” section). The semantics get enforced concretely.