home / skills / duc01226 / easyplatform / test-ui

test-ui skill

/.claude/skills/test-ui

This skill automates browser testing and performance analysis with Puppeteer, helping you capture screenshots, inspect networks, and debug JavaScript

npx playbooks add skill duc01226/easyplatform --skill test-ui

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

Files (25)
SKILL.md
5.5 KB
---
name: test-ui
description: "[DevOps & Infra] Browser automation, debugging, and performance analysis using Puppeteer CLI scripts. Use for automating browsers, taking screenshots, analyzing performance, monitoring network traffic, web scraping, form automation, and JavaScript debugging."
license: Apache-2.0
version: 1.2.0
---

# Chrome DevTools Agent Skill

Browser automation via Puppeteer scripts with persistent sessions. All scripts output JSON.

## Summary

**Goal:** Automate browser interactions, take screenshots, and analyze performance using Puppeteer CLI scripts.

| Step | Action | Key Notes |
|------|--------|-----------|
| 1 | Install | `cd .claude/skills/test-ui/scripts && npm install` |
| 2 | Navigate | `node navigate.js --url <url>` (session persists via `.browser-session.json`) |
| 3 | Interact | `click.js`, `fill.js`, `evaluate.js`, `select-ref.js` |
| 4 | Inspect | `screenshot.js`, `snapshot.js`, `aria-snapshot.js`, `console.js` |
| 5 | Analyze | `performance.js` for Core Web Vitals, `network.js` for HTTP tracking |
| 6 | Close | `node navigate.js --url about:blank --close true` |

**Key Principles:**
- Never use `file://` for local HTML -- serve via `npx serve` instead
- Session persists between scripts; delete `.browser-session.json` to reset
- Source-available sites: read source first for selectors; unknown layouts: use `aria-snapshot.js`

## ⚠️ MUST READ References

**IMPORTANT: You MUST read these reference files for complete protocol. Do NOT skip.**

- **⚠️ MUST READ** `references/devtools-patterns.md` — ARIA, screenshots, console, custom scripts
- **⚠️ MUST READ** `references/cdp-domains.md` — CDP domain reference
- **⚠️ MUST READ** `references/puppeteer-reference.md` — Puppeteer API reference
- **⚠️ MUST READ** `references/performance-guide.md` — Performance analysis guide
- **⚠️ MUST READ** `scripts/README.md` — Script options reference

## Choosing Your Approach

| Scenario               | Approach                                           |
| ---------------------- | -------------------------------------------------- |
| Source-available sites | Read source code first, write selectors directly   |
| Unknown layouts        | Use `aria-snapshot.js` for semantic discovery      |
| Visual inspection      | Take screenshots to verify rendering               |
| Debug issues           | Collect console logs, analyze with session storage |

## Quick Start

```bash
cd .claude/skills/test-ui/scripts
npm install
node navigate.js --url https://example.com
# Headless on Linux/WSL/CI; headed on macOS/Windows
# Linux/WSL: Run ./install-deps.sh first for Chrome system libraries
```

## Session Persistence

Browser state persists via `.browser-session.json`. Scripts disconnect but keep browser running.

```bash
node navigate.js --url https://example.com/login
node fill.js --selector "#email" --value "[email protected]"
node click.js --selector "button[type=submit]"
node navigate.js --url about:blank --close true   # Close when done
```

## Available Scripts

All in `.claude/skills/test-ui/scripts/`:

| Script             | Purpose                                      |
| ------------------ | -------------------------------------------- |
| `navigate.js`      | Navigate to URLs                             |
| `screenshot.js`    | Capture screenshots (auto-compress >5MB)     |
| `click.js`         | Click elements                               |
| `fill.js`          | Fill form fields                             |
| `evaluate.js`      | Execute JS in page context                   |
| `snapshot.js`      | Extract interactive elements (JSON)          |
| `aria-snapshot.js` | Get ARIA accessibility tree (YAML with refs) |
| `select-ref.js`    | Interact with elements by ARIA ref           |
| `console.js`       | Monitor console messages/errors              |
| `network.js`       | Track HTTP requests/responses                |
| `performance.js`   | Measure Core Web Vitals                      |

## Script Options (All scripts)

- `--headless false` - Show browser window
- `--close true` - Close browser completely
- `--timeout 30000` - Set timeout (ms)
- `--wait-until networkidle2` - Wait strategy

## Common Patterns

```bash
# Web scraping
node evaluate.js --url https://example.com --script "
  Array.from(document.querySelectorAll('.item')).map(el => ({
    title: el.querySelector('h2')?.textContent, link: el.querySelector('a')?.href
  }))" | jq '.result'

# Form automation
node fill.js --selector "#search" --value "query"
node click.js --selector "button[type=submit]"

# Performance
node performance.js --url https://example.com | jq '.vitals'
```

## Local HTML Files

**Never use `file://`.** Serve via local server: `npx serve ./dist -p 3000 &`

## Troubleshooting

| Error                             | Solution                                      |
| --------------------------------- | --------------------------------------------- |
| `Cannot find package 'puppeteer'` | Run `npm install` in scripts directory        |
| `libnss3.so` missing (Linux)      | Run `./install-deps.sh`                       |
| Element not found                 | Use `snapshot.js` to find correct selector    |
| Script hangs                      | Use `--timeout 60000` or `--wait-until load`  |
| Screenshot >5MB                   | Auto-compressed; use `--max-size 3` for lower |
| Session stale                     | Delete `.browser-session.json` and retry      |


## IMPORTANT Task Planning Notes

- Always plan and break many small todo tasks
- Always add a final review todo task to review the works done at the end to find any fix or enhancement needed

Overview

This skill automates browser interactions, captures screenshots, monitors network traffic, and performs performance analysis using Puppeteer CLI scripts. It preserves a persistent browser session between commands and returns JSON outputs for integration into pipelines and tooling. Use it for debugging, scraping, accessibility inspection, and Core Web Vitals measurement.

How this skill works

The skill runs small Node.js CLI scripts that connect to a running Chromium instance and perform actions like navigation, clicking, filling forms, evaluating page JS, and capturing screenshots. Session state is stored so scripts can disconnect while keeping the browser running, enabling multi-step workflows. Output from every script is emitted as JSON for easy parsing and automation.

When to use it

  • Automate end-to-end interactions and form flows for CI or manual testing
  • Take visual evidence via screenshots for visual regression or rendering verification
  • Collect console logs and network traces to debug client-side errors and resource issues
  • Run performance audits and extract Core Web Vitals programmatically
  • Discover DOM/ARIA structure when selectors are unclear or when testing accessibility

Best practices

  • Run scripts from the scripts directory and install dependencies before use (npm install)
  • Serve local HTML over HTTP (don’t use file://); use a lightweight local server for assets
  • Keep workflows small and composable: one script per action (navigate, fill, click, screenshot)
  • Use persistent session to chain steps; delete the session file to reset state
  • Prefer aria-based discovery for unknown layouts and source inspection for known projects

Example use cases

  • Headless CI test: navigate to a page, run performance audit, and fail build on poor vitals
  • Bug triage: reproduce an error, collect console logs, network trace, and screenshots to attach to an issue
  • Form automation: fill login fields, submit, and verify success message programmatically
  • Web scraping: run an evaluate script to extract lists of items and output structured JSON
  • Accessibility check: generate an ARIA snapshot to locate interactive elements and references

FAQ

How do I reset the browser session?

Delete the persistent session file to start a fresh browser instance and session state will be reset.

Can I run the browser in headed mode for debugging?

Yes — pass the headless flag (--headless false) to show the browser window for interactive debugging.

How do I test local builds that use relative assets?

Serve the built files over HTTP (for example with a lightweight static server) rather than opening file:// URLs to ensure correct resource loading.