Screenshot capture on test failure (GNOME, focused-window) #18
Labels
No labels
area:assertions
area:cli
area:client
area:harness
area:meta
area:reporting
area:runner
type:user-story
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/ws-rpc-test#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As a test author whose app under test has a GUI on GNOME, I want a screenshot of the app's window captured automatically the moment a test fails, so that I can diagnose visual bugs ("wrong dialog appeared", "window froze", "modal stuck behind another window") without having to reproduce the failure interactively — and without leaking unrelated desktop content into the artifact.
Scope
v0.1 targets GNOME only (both X11 and Wayland sessions). Other desktops (Sway, Hyprland, KDE, generic X11) are explicitly deferred — the user is on GNOME and we'd rather have one well-tested path than five half-working ones.
The captured window is the focused window at the moment of failure, not a PID-resolved one. This works because:
This stays within the framework's non-goal of "browser/DOM testing" — it's a passive raster snapshot, not DOM introspection.
Acceptance criteria
Configuration
RunConfig.screenshot_on_failure: bool(defaultfalse).RunConfig.screenshot_dir: PathBuf(default./test-screenshots/).--screenshot-on-failure,--screenshot-dir <PATH>wired through #15.TestRunner:runner.screenshot_on_failure(dir).Capture trigger
Erroutcome that isn'tSkip), the runner attempts to capture a screenshot before runningafter_eachso cleanup hooks don't alter what's on screen.Capture mechanism (GNOME)
The framework uses GNOME-native interfaces only. Both X11 and Wayland sessions are supported through the same code path because GNOME Shell exposes the same D-Bus interface in both.
org.gnome.Shell.Screenshot, methodScreenshotWindow: Args:include_frame=false,include_cursor=false,flash=false,filename. Captures the currently focused window. Works on GNOME X11 and Wayland.gnome-screenshot --window --file=<output_path>if the D-Bus call fails (older GNOME install, stripped Shell, etc.).gdbus/gnome-screenshotare not installed, log a one-line warning to stderr (screenshot capture skipped: GNOME Shell screenshot interface unavailable (gdbus rc=N, gnome-screenshot rc=N)) and continue. Do not fall back to full-screen.Session detection & gating
screenshot_on_failureis enabled), probe once:gdbusonPATH?gdbus introspect --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Screenshotsucceed?gnome-screenshotis available, log a one-line warning at startup and disable screenshot capture for the run.XDG_CURRENT_DESKTOP(GNOME,GNOME-Classic,ubuntu:GNOME, etc.). On other desktops, log a one-line warning at startup naming the detected desktop and disable screenshot capture for the run.DISPLAY/WAYLAND_DISPLAY/XDG_RUNTIME_DIR/DBUS_SESSION_BUS_ADDRESSfrom the same env the harness child sees.Output
{screenshot_dir}/{timestamp}_{test_name_sanitized}.pngwheretimestampisYYYYMMDD-HHMMSS-mmm(millisecond precision to avoid collisions in fast suites) andtest_name_sanitizedreplaces non-alphanumerics with_.fs::create_dir_all).TestCaseResult.screenshot: Option<PathBuf>.Nonemeans capture was attempted but skipped or failed.Reporter integration
Screenshot: ./test-screenshots/20260411-103045-123_generation_cancel.png"screenshot": "<path>"in the test object when captured (omitted otherwise).<failure>body and as a<system-out>element so CI dashboards (Jenkins, GitLab) pick it up as an artifact.Tests
gdbusscript thattouches a PNG when called with the expected args; assert path-storage and reporter integration.gdbusreturns non-zero, fakegnome-screenshotproduces the file, capture still succeeds.screenshoton the test result isNone.XDG_CURRENT_DESKTOP=KDE, confirm capture is disabled at startup with a warning and never attempted.gdbusscript thatsleep 30s gets killed within ~5 s and the test still completes.Documentation requirement
The README and the
RunConfig.screenshot_on_failuredoc comment must clearly state:Out of scope (still deferred)
References
DISPLAY/XDG_RUNTIME_DIRand exposes the child PIDOptional screenshot capture on test failure for GUI apps under testto Screenshot capture on test failure (app-window-only) for GUI apps under testScreenshot capture on test failure (app-window-only) for GUI apps under testto Screenshot capture on test failure (app-window only)Screenshot capture on test failure (app-window only)to Screenshot capture on test failure (GNOME, focused-window)