A YAML-based Playwright MCP automation testing framework designed for Claude Code
中文文档 | English Documentation
Live demonstration project for the claude-test CLI framework - showcasing intelligent automation testing powered by Claude Code + Playwright MCP with natural language YAML-based testing, dynamic element targeting, multi-environment configuration, and session persistence.
This is a demonstration and example project for the claude-test CLI tool. While this project contains working test cases and comprehensive documentation, the actual framework code and CLI commands have been moved to the official claude-test
npm package.
Unlike traditional Playwright automation that relies on fragile CSS selectors or XPath expressions, Playwright MCP uses a revolutionary dynamic element identification system:
flowchart TD
A["🌐 Web Page Loaded"] --> B["🔍 Playwright MCP Scans Page"]
B --> C["🏷️ Assigns Unique ref_id to Each Element"]
C --> D["📋 Creates Accessibility Snapshot"]
D --> E["🤖 Claude Code Receives Element Map"]
E --> F["🗣️ User Writes Natural Language Step"]
F --> G["🎯 Claude Matches Description to ref_id"]
G --> H["⚡ Executes Precise Action"]
style A fill:#4CAF50,stroke:#2E7D32,stroke-width:3px,color:#ffffff
style B fill:#2196F3,stroke:#1565C0,stroke-width:3px,color:#ffffff
style C fill:#FF9800,stroke:#F57C00,stroke-width:3px,color:#ffffff
style D fill:#9C27B0,stroke:#6A1B9A,stroke-width:3px,color:#ffffff
style E fill:#F44336,stroke:#C62828,stroke-width:3px,color:#ffffff
style F fill:#607D8B,stroke:#37474F,stroke-width:3px,color:#ffffff
style G fill:#3F51B5,stroke:#283593,stroke-width:3px,color:#ffffff
style H fill:#4CAF50,stroke:#2E7D32,stroke-width:3px,color:#ffffff
When Playwright MCP accesses a web page, it automatically:
Instead of guessing selectors, Claude Code can:
# Your YAML test step:
- "Click Add to Cart button for first product"
# What happens behind the scenes:
# 1. Playwright MCP identifies all "Add to Cart" buttons
# 2. Assigns ref_ids: button[ref_id="addcart_123"], button[ref_id="addcart_456"]
# 3. Claude Code intelligently selects the first one: ref_id="addcart_123"
# 4. Executes precise click action without guessing selectors
Traditional Approach | Playwright MCP Approach |
---|---|
page.click('#add-cart-btn-1') | Claude sees "Add to Cart button for Sauce Labs Backpack" with ref_id |
Brittle CSS selectors | Dynamic element identification |
Breaks when HTML changes | Adapts to page structure automatically |
Requires manual maintenance | Self-healing element detection |
Multiple retry attempts | First-time accurate targeting |
This is why our YAML-based approach is so powerful - you write in natural language, and Playwright MCP handles the complex element targeting automatically.
Watch the live demonstration of YAML-based Playwright testing in action:
📺 Watch Demo Video - See how to write and execute tests using natural language with Claude Code and Playwright MCP.
We're actively working on exciting new features to make YAML-based testing even more powerful:
.mdc
rule file for Cursor AI integration/run-yaml-test
command support in Cursor# Example: test-suites/e-commerce.yml
name: "E-commerce Test Suite"
description: "Complete e-commerce workflow testing"
tags:
- e-commerce
- integration
test-cases:
- "test-cases/order.yml"
- "test-cases/product-details.yml"
- "test-cases/sort-optimized.yml"
Available Suite Commands:
/run-test-suite suite:e-commerce.yml env:test
/validate-test-suite suite:smoke-tests.yml env:dev
Feature | Status | Expected Release |
---|---|---|
✅ Cursor IDE Support | ✅ Completed | ✅ Released |
✅ Test Suites Support | ✅ Completed | ✅ Released |
npm install -g claude-test
claude mcp add playwright -- npx -y @playwright/mcp@latest \
--user-data-dir ~/.cache/claude-playwright \
--storage-state ~/.cache/claude-playwright/auth-state.json \
--save-trace \
--output-dir ~/CascadeProjects/claude-code-playwright-mcp-test/screenshots
# Create a new project with the framework
cd your-new-project
claude-test init
# Clone this demo project
git clone https://github.com/terryso/claude-code-playwright-mcp-test.git
cd claude-code-playwright-mcp-test
# Execute order test
/run-yaml-test file:test-cases/order.yml env:dev
# View reports
/view-reports-index
# test-cases/example.yml
tags:
- smoke
steps:
- include: "login"
- "Click Add to Cart button for first product"
- "Click shopping cart icon"
- "Verify cart contains 1 item"
📈 Latest Test Report - Automatically generated after each test run, showing detailed execution results, screenshots, and performance metrics.
Have ideas for new features? We'd love to hear from you!
enhancement
labelgit checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
/help
in Claude Code for more assistanceHappy Testing! 🚀
This demo project showcases the power of the claude-test CLI framework. For new projects, install the CLI globally and use claude-test init
to get started.
{ "mcpServers": { "claude-code-playwright-mcp-test": { "command": "claude", "args": [ "mcp", "add", "playwright", "--", "npx", "-y", "@playwright/mcp@latest", "--user-data-dir", "~/.cache/claude-playwright", "--storage-state", "~/.cache/claude-playwright/auth-state.json", "--save-trace", "--output-dir", "~/CascadeProjects/claude-code-playwright-mcp-test/screenshots" ] } } }
Related projects feature coming soon
Will recommend related projects based on sub-categories