Files
Tirsvad e764269eda Implement the Selenium lecture steps with tests and screenshots (MIL-002)
Driver factory, click_link_by_text, search_for, fill_out_form, run_lecture
and CLI, layered as domain, application, infrastructure and presentation.
30 offline unit tests, a form fixture, a Docker image for headless runs and
four screenshots captured in Docker. Reviews RC-009 (code) and RC-010
(milestone wording of the screenshot criterion).

Task: MIL-002#1
2026-10-28 16:22:41 +08:00

39 lines
1.1 KiB
Python

from typing import Any
class FakeElement:
"""Records the interactions with one element in a shared event list."""
def __init__(self, events: list[tuple[Any, ...]], locator: tuple[str, str]) -> None:
self._events = events
self.locator = locator
def click(self) -> None:
self._events.append(("click", self.locator))
def send_keys(self, *value: str) -> None:
self._events.append(("send_keys", self.locator, value))
class FakeBrowser:
"""Records every call in order, without any browser."""
def __init__(self) -> None:
self.events: list[tuple[Any, ...]] = []
self.screenshots: list[str] = []
def get(self, url: str) -> None:
self.events.append(("get", url))
def find_element(self, by: str, value: str) -> FakeElement:
self.events.append(("find_element", by, value))
return FakeElement(self.events, (by, value))
def save_screenshot(self, filename: str) -> bool:
self.screenshots.append(filename)
self.events.append(("save_screenshot", filename))
return True
def quit(self) -> None:
self.events.append(("quit",))