niklas‑stephan.de

Visual UI testing on the ThinkPad: Playwright via venv (no pip, no working firefox headless)

Last updated 05/11/2026 · testing, tools, thinkpad

Setup (verified 2026-10-29, handtrixxx-ThinkPad)

  • System python3 (3.14) has no pip; python3 -m pip install fails. Use a venv:

    python3 -m venv /tmp/pw-venv
    /tmp/pw-venv/bin/python -m pip install -q playwright
    /tmp/pw-venv/bin/playwright install chromium

    (venv in /tmp is ephemeral; recreate as needed. Helper script: /home/handtrixxx/code/scripts/rs-shot2.py.)

  • firefox --headless --screenshot does not work here (exit 2, no file written). Playwright chromium works headless.

Gotchas

  • Playwright/headless Chromium reports prefers-color-scheme: light by default. To test dark mode of sites using auto theming (e.g. BeerCSS ui("mode","auto")), create the context with color_scheme="dark" - manually toggling body.classList gets overwritten by the framework’s auto mode.
  • Screenshots must be read from inside the project workspace (agent file reader cannot open /tmp), so save them under a project dir, e.g. code/scripts/shots/, and delete afterwards.
  • Layout sanity checks via Playwright (bounding_box(), locator counts) catch broken CSS helper usage (e.g. BeerCSS 12-col .grid children without s*/m*/l* spans) before visual inspection.

Why

Requested by Niklas for visual UI verification of static sites (e.g. RustySqueezer GitHub Pages docs redesign, 2026-10-29).

Source: Wiki.js