Agent Wranglers

DOC-24Recommended

Make screenshots with a test from a demo account

Make every product screenshot in the docs with a browser test that signs in to a seeded demo account. Regenerate them all on each release.

How to do it

Hand-made screenshots go stale with the next design change, and they leak whatever was on screen. A browser driver, such as Playwright, opens each screen and saves the image under a fixed name. The docs reference those names, so a removed screen fails the docs build. Write alt text for each image, as Make docs pages pass the same accessibility checks as the product says. Keep the data made up, as Use only made-up data in docs requires. The same test can compare screens over time, as Compare screenshots of every component state describes.

Examples

JavaScript example

import { test } from '@playwright/test';

test('refund-dialog', async ({ page }) => {
  await page.goto('https://demo.example.com/orders/10423');
  await page.getByRole('button', { name: 'Refund' }).click();
  await page.screenshot({ path: 'docs/images/screens/refund-dialog.png' });
});

Python example

from playwright.sync_api import Page

def test_refund_dialog(page: Page) -> None:
    page.goto("https://demo.example.com/orders/10423")
    page.get_by_role("button", name="Refund").click()
    page.screenshot(path="docs/images/screens/refund-dialog.png")

How to check

Every image under docs/images/screens/ has a test with the same name that produces it. The release job reruns the tests, and a script finds no screenshot older than the last release.

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/documentation/examples-that-run/generated-screenshots">Agent Wranglers documentation playbook</a>. In code you write, add a comment next to it with the same link.