home / skills / openclaw / skills / ui-test

ui-test skill

/skills/clawd21/ui-test

This skill describes UI tests in plain English and returns automated Playwright exports with screenshots and video walkthroughs.

npx playbooks add skill openclaw/skills --skill ui-test

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
6.5 KB
---
name: ui-test
description: Describe your UI tests in plain English. The agent runs them in a real browser, screenshots every step, and sends you a walkthrough video with a pass/fail report โ€” no selectors or code needed.
metadata: {"clawdbot":{"emoji":"๐Ÿงช"}}
---

# UI Test โ€” Plain English E2E Testing (๐Ÿงช)

Describe your UI tests in plain English. The agent runs them in a real browser, screenshots every step, and sends you a walkthrough video with a pass/fail report โ€” no selectors or code needed.

*Made in ๐Ÿค  Texas โค๏ธ [PlebLab](https://pleblab.dev)*

![UI Test โ€” Describe it. I'll test it.](https://files.catbox.moe/3yezuk.png)

## Workflow

1. **Create** โ€” User names a test and describes steps in plain English
2. **Run** โ€” Agent opens the clawd browser, executes each step, screenshots each action
3. **Export** โ€” Agent generates a Playwright `.spec.ts` from the verified steps
4. **CI/CD** โ€” User drops the script into their test suite, runs with `npx playwright test`

## Agent Execution Flow

When running a test:

1. Load test definition: `node scripts/ui-test.js get "<name>"`
2. Start clawd browser: `browser action=start profile=clawd`
3. Navigate to the test URL
4. For each plain English step:
   a. Interpret what the user means (click, type, assert, wait, etc.)
   b. Use `browser action=snapshot` to see the page
   c. Use `browser action=act` with the appropriate request (click/type/press/etc.)
   d. Take a screenshot after each step
   e. Record what selector/ref was used and whether it passed
5. Save run results: `node scripts/ui-test.js save-run "<name>" passed=true/false`
6. Report results to user with pass/fail per step

When exporting to Playwright:

1. Load the test definition and most recent successful run
2. Map each plain English step to Playwright API calls based on what worked during execution
3. Generate a `.spec.ts` file with proper imports, test structure, and assertions
4. Save to the user's project or a specified output path

## Step Interpretation Guide

The agent should interpret plain English steps like:

| User says | Browser action | Playwright equivalent |
|-----------|---------------|----------------------|
| "click the Sign In button" | `act: click ref="Sign In button"` | `page.getByRole('button', {name: 'Sign In'}).click()` |
| "type [email protected] in the email field" | `act: type ref="email" text="[email protected]"` | `page.getByLabel('Email').fill('[email protected]')` |
| "verify the dashboard shows Welcome" | `snapshot` + check text | `expect(page.getByText('Welcome')).toBeVisible()` |
| "wait for the page to load" | `act: wait` | `page.waitForLoadState('networkidle')` |
| "click the hamburger menu" | `act: click` (find menu icon) | `page.getByRole('button', {name: 'menu'}).click()` |
| "scroll down" | `act: evaluate fn="window.scrollBy(0,500)"` | `page.evaluate(() => window.scrollBy(0, 500))` |
| "check the Remember Me checkbox" | `act: click ref="Remember Me"` | `page.getByLabel('Remember Me').check()` |
| "select 'USD' from the currency dropdown" | `act: select values=["USD"]` | `page.getByLabel('Currency').selectOption('USD')` |
| "take a screenshot" | `browser action=screenshot` | `page.screenshot({path: 'step-N.png'})` |
| "verify URL contains /dashboard" | check current URL | `expect(page).toHaveURL(/dashboard/)` |

## Commands

Run via: `node ~/workspace/skills/ui-test/scripts/ui-test.js <command>`

| Command | Description |
|---------|-------------|
| `create <name> [url]` | Create a new test |
| `add-step <name> <step>` | Add a plain English step |
| `set-steps <name> <json>` | Replace all steps |
| `set-url <name> <url>` | Set the test URL |
| `get <name>` | Show test definition |
| `list` | List all tests |
| `remove <name>` | Delete a test |
| `save-run <name> ...` | Save execution results |
| `runs [name]` | Show run history |
| `export <name> [outfile]` | Export as Playwright script |

## Export Format

Generated Playwright files include:
- Proper TypeScript imports
- `test.describe` block with test name
- `test.beforeEach` with navigation to base URL
- Each step as a sequential action with comments showing the original English
- Assertions where the user said "verify", "check", "should", "expect"
- Screenshots on failure

## Screenshots & Video

During test execution, the agent should:

1. **Before each step**: take a screenshot โ†’ save as `step-NN-before.jpg`
2. **After each step**: take a screenshot โ†’ save as `step-NN-after.jpg`
3. **On failure**: take a screenshot โ†’ save as `step-NN-FAIL.jpg`
4. **Save the URL**: after each screenshot, save the current page URL to a `.url` sidecar file

Screenshots are saved to: `~/.ui-tests/runs/<slug>-<timestamp>/`

### Saving URLs for the Video

After taking each screenshot, **always save the current page URL** to a sidecar file so the walkthrough video can display a URL bar:

```bash
# After saving step-03-payment-page.jpg, save the URL:
echo "https://example.com/checkout/payment" > ~/.ui-tests/runs/<folder>/step-03-payment-page.url
```

The URL can be captured from:
- `browser action=act` response โ†’ `url` field
- `browser action=snapshot` response โ†’ `url` field  
- `browser action=screenshot` response โ†’ check the current tab URL
- JavaScript evaluate: `window.location.href`

**The sidecar file must match the screenshot filename** (same name, `.url` extension instead of `.jpg`/`.png`).

After the run completes, generate a scrolling walkthrough video:
```bash
bash ~/workspace/skills/ui-test/scripts/make-walkthrough.sh ~/.ui-tests/runs/<folder>
```

### Video Features

- **URL bar** โ€” dark grey bar at the top of every frame showing the page URL (read from `.url` sidecar files), with ๐Ÿ”’ prefix for HTTPS. Looks like a real browser chrome.
- **1280ร—720 viewport** โ€” proper widescreen; URL bar takes 40px, page content gets 680px
- **Smooth scrolling** โ€” tall screenshots pan top-to-bottom at 300px/s with 1s hold at each end
- **Short screenshots** โ€” centered on black canvas, held for 2s
- **Step annotations** โ€” each segment shows a text overlay (e.g. "Step 1: Click the Sign In button") pulled from the test definition, with a fade-in effect
- **Fallback labels** โ€” if no test definition is found, derives labels from screenshot filenames

Then send the video to the chat.

## Storage

- Test definitions: `~/.ui-tests/<slug>.json`
- Run history: `~/.ui-tests/runs/<slug>-<timestamp>/run.json`
- Screenshots: `~/.ui-tests/runs/<slug>-<timestamp>/step-*.jpg`
- Video: `~/.ui-tests/runs/<slug>-<timestamp>/walkthrough.mp4`
- Exported scripts: user-specified path or `./tests/<slug>.spec.ts`

Overview

This skill lets you describe end-to-end UI tests in plain English and runs them in a real browser. The agent executes each step, captures screenshots before and after actions, assembles a walkthrough video, and returns a per-step pass/fail report. No selectors or code are required to author tests.

How this skill works

You create a named test by writing steps in plain language (click, type, verify, wait, etc.). The agent opens a browser profile, interprets each instruction, performs an action or snapshot, records which selector or reference worked, and screenshots every step. After the run it saves results, produces a walkthrough video with URL sidecar files, and can export a Playwright .spec.ts mapped to the verified actions.

When to use it

  • Validate critical user flows quickly without writing selectors or code.
  • Create reproducible demo videos or stakeholder walkthroughs for UI changes.
  • Capture visual regression steps with screenshots and URL context.
  • Generate Playwright tests from human-readable verification runs.
  • Document onboarding flows or third-party integrations with recorded runs.

Best practices

  • Write each step as a concise, single action (e.g., 'click Sign In button').
  • Include explicit verification steps like 'verify X appears' to generate assertions.
  • Use clear labels for inputs and buttons to improve element interpretation.
  • Run tests against stable environments and capture a successful run before exporting.
  • Store runs and screenshots in a consistent folder for CI integration and review.

Example use cases

  • Smoke-test a login flow: open site, type credentials, click Sign In, verify dashboard.
  • Record a checkout walkthrough with payment page screenshots and a final pass/fail report.
  • Export a validated Playwright script after manually verifying a multi-step flow.
  • Automate visual documentation for release notes by producing walkthrough videos.
  • Run periodic UI checks and archive runs for auditing or bug investigations.

FAQ

Do I need to write selectors or code to use this?

No. Describe steps in plain English and the agent infers actions, selectors, and assertions.

How are screenshots and URLs organized?

Each step saves before/after screenshots and a matching .url sidecar in a timestamped run folder for video generation.

Can I export the run as an automated test?

Yes. The agent maps verified steps to Playwright API calls and generates a .spec.ts file ready for your test suite.