published fresh until

Playwright: polish agent UI with screenshot feedback?

Summary As of October 2026, give the agent a fixed viewport, stable page state and a short ranked critique, then recapture after each small change; approve the design before adding toHaveScreenshot assertions and running npx playwright test tests/ui-polish.spec.ts --project=chromium

Not for Playwright screenshot baseline approval, see agent-ui-change-who-approves-new-screenshot-baselines

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Use Playwright to capture the same page state before and after each small UI change, and give the agent a ranked, observable critique.

Do first: Add tests/ui-polish.spec.ts to your existing Playwright project using the capture test below.

Choose one route, sample data, viewport and reference image or written design goal. Preserve the same browser, fonts, theme and page state in each capture. A different viewport or loading state can look like a design regression.

1. Capture desktop and mobile before asking for edits. In an existing Playwright project, add a focused capture test, replacing the route with the configured app URL or baseURL route:

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

test('capture screen for critique', async ({ page }, testInfo) => {
  await page.setViewportSize({ width: 1280, height: 800 });
  await page.goto('/dashboard');
  await expect(page.getByRole('heading', { name: 'Dashboard', exact: true }))
    .toBeVisible();
  await page.evaluate(() => document.fonts.ready);
  await page.screenshot({
    path: testInfo.outputPath('desktop.png'),
    fullPage: true,
    animations: 'disabled',
  });
  await page.setViewportSize({ width: 390, height: 844 });
  await page.screenshot({
    path: testInfo.outputPath('mobile.png'),
    fullPage: true,
    animations: 'disabled',
  });
});

Run npx playwright test tests/ui-polish.spec.ts --project=chromium after adapting the filename and project name. The viewport sizes are suggested review fixtures. Playwright documents page and element captures; the heading check should be replaced with an application-specific ready state when necessary.

2. Inspect both images. Give the agent at most three prioritized defects, each tied to a location and expected change. For example: align the content heading with the card edge; make the primary action distinguishable from secondary actions; remove horizontal clipping on mobile. Supply a reference image when exact matching matters. 3. Ask for the smallest component or token edits that address those defects. Recapture the same states and compare side by side. Require the agent to report remaining mismatches, not merely that the code builds. 4. Stop when the named defects are resolved and interaction checks still pass. If progress stalls, make a human design decision rather than request another broad redesign. 5. After human approval, replace the exploratory capture with assertions such as await expect(page).toHaveScreenshot('dashboard.png', { fullPage: true }); for the reviewed states. Playwright's visual comparison guide describes creating and reviewing reference images. Initial baseline generation is an approval step, not proof of good design.

Which feedback works?

ApproachWhat it is for / when it winsWhen it losesPick this if
Manual capture and annotated critiqueOne screen, early exploration and human tasteEasy to change viewport or state between roundsYou need a quick one-off correction
Repeatable Playwright captureSeveral routes, repeated edits and regression checksRequires fixtures and browser setup; pixel equality cannot judge tasteThe agent will revisit the UI repeatedly

Solo: start with manual critique and one reproducible capture. Small team: use a shared capture fixture and one reviewer. Enterprise: use deterministic fixtures, reviewed reference images and a separate accessibility/interaction check. These are proposed workflow defaults, not measured productivity claims.

Tool status and limits — checked 2026-11-17

As of November 2026, the Playwright release is 1.65.1. This workflow uses your existing test tooling and browser compute; no hosted visual-testing subscription is required. Agent model usage remains a separate cost.

toHaveScreenshot waits for consecutive stable images and disables animations by default; see its API reference. Avoid masking the very region being reviewed. Consistent OS/browser/font settings matter; a large pixel allowance can hide a real layout defect.

Public user evidence

robstoll, 2025-05-20, issue #35972 reported: “The problem seems to be a concurrency issue”. The discussion includes screenshot timeouts around incomplete resource loading. It supports stabilizing page readiness, not a claim that this critique loop improves design quality.

Prompt for the agent

Inspect desktop.png and mobile.png against the reference and our spacing/type rules. Rank the three largest observable mismatches. Fix only those, reuse existing components, and recapture both at identical viewports and sample data. List what improved and what remains. Test the primary action and keyboard navigation; do not approve new reference images yourself.

Mistakes and limits

Avoid “make it premium” without an inspectable target, changing every component at once, and treating a matching screenshot as an accessibility check. A screenshot misses hover, focus, scrolling and many loading/error behaviors; inspect those separately. The sample capture and UI iteration were not executed. Evidence for screenshot mechanics is stronger than evidence for agent design improvement; no improvement rate is claimed.

Started from a post by @Microsoft Playwright team, packaged by the editor. Original post

Subjects

More in motion design

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Playwright: polish agent UI with screenshot feedback?
Summary: As of October 2026, give the agent a fixed viewport, stable page state and a short ranked critique, then recapture after each small change; approve the design before adding toHaveScreenshot assertions and running `npx playwright test tests/ui-polish.spec.ts --project=chromium`
Copy for agent
get the whatworks thread playwright-screenshot-feedback-polish-agent-ui and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread playwright-screenshot-feedback-polish-agent-ui
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp