Playwright MCP Testing
Install this skill
npx skills add sfc-gh-dflippo/snowflake-dbt-demoWorks across Claude Code, Cursor, Codex, Copilot & Antigravity
What this skill does
- β’Programmatic navigation and viewport resizing
- β’DOM state analysis via accessibility tree snapshots
- β’Batch form submission for rapid testing
- β’Visual capture and screenshot comparison
- β’Real-time inspection of browser console messages
When to use it
- βVerifying application behavior after code changes
- βTesting form validation logic and successful submission flows
- βAuditing UI responsiveness across mobile, tablet, and desktop viewports
- βIdentifying client-side JavaScript errors during page initialization
When not to use it
- βHigh-frequency unit testing of pure logic functions
- βPerformance testing that requires deep network latency analysis
- βScraping highly protected sites with complex anti-bot measures
How to invoke it
Example prompts that trigger this skill:
- βNavigate to the login page and take a snapshot to list form fields.β
- βResize the browser to mobile dimensions and check for UI layout issues.β
- βFill out the registration form with test credentials and submit it.β
- βCheck the browser console for any JavaScript errors on the dashboard.β
- βCapture a screenshot of the main landing page to verify visuals.β
Example workflow
- Open the target URL using the navigate tool.
- Request an accessibility snapshot to identify interactive button refs.
- Execute interaction commands using retrieved element references.
- Wait for a success message or specific state change.
- Verify results by checking for console errors and visual state.
Prerequisites
- βPlaywright browser binaries installed via 'npx @playwright/mcp browser install'
- βNode.js runtime environment
Pitfalls & limitations
- !Assuming elements are immediately available without explicit wait commands.
- !Over-relying on visual screenshots instead of semantic snapshots for interaction.
- !Missing dynamic state updates if wait durations are too short.
FAQ
How it compares
Unlike manual testing or generic Puppeteer scripts, this MCP implementation provides an AI-native interface, allowing the agent to interpret the page structure automatically via snapshots instead of requiring hardcoded selectors.
Source & trust
From the source: β# Playwright MCP Testing Automate browser testing, web scraping, and UI validation using Playwright MCP server for comprehensive browser automation. ## Quick Start **Core Testing Workflow:** 1. Navigate to application 2. Take snapshot (accessibility tree) 3. Interact with elements 4. Verify expectedβ¦β
View the full SKILL.md source
# Playwright MCP Testing Automate browser testing, web scraping, and UI validation using Playwright MCP server for comprehensive browser automation. ## Quick Start **Core Testing Workflow:** 1. Navigate to application 2. Take snapshot (accessibility tree) 3. Interact with elements 4. Verify expected behavior 5. Take screenshots for documentation ## Key Tools ### Navigation & Waiting - `browser_navigate` - Load URL - `browser_wait_for` - Wait for time, text, or element ### Interaction - `browser_click` - Click buttons and elements - `browser_fill_form` - Batch fill multiple form fields - `browser_type` - Type into inputs - `browser_select_option` - Select dropdown options ### Validation - `browser_snapshot` - Accessibility tree (for AI analysis) - `browser_take_screenshot` - Visual capture - `browser_console_messages` - Check for JavaScript errors ## Testing Patterns ### Page Load Verification ```sql Navigate to http://localhost:8501 Wait 5 seconds Take snapshot Verify expected elements present ``` ### Form Testing ```sql Fill form fields (use browser_fill_form for speed) Click Submit button Wait for "Success" text to appear Take screenshot ``` ### Responsive Design ```sql Resize to 375x667 (mobile) Take screenshot Resize to 1920x1080 (desktop) Take screenshot ``` ### Multi-Page Navigation ```sql Navigate to homepage Click navigation link Verify URL changed Verify new page content ``` ## Best Practices β **DO:** - Use `browser_snapshot` for AI analysis - Wait for content (3-5 seconds) - Batch form fields with `browser_fill_form` - Use element refs from snapshots for reliable clicks - Check console for errors β **AVOID:** - Using screenshots when you need to interact - Typing each field individually - Skipping waits for dynamic content - Ignoring console errors ## Common Workflows ### Pre-Deployment Testing - Test all pages load without errors - Verify navigation works - Test forms submit successfully - Check data displays correctly - Validate responsive design (375, 768, 1920px) - Check console for JavaScript errors ### Accessibility Validation - Take snapshot of each page - Verify interactive elements have labels - Check heading hierarchy - Verify form labels associated ### Visual Regression - Take full-page screenshots - Compare with baseline - Document changes ## Quick Reference ### Common Test Flow ```sql Navigate to http://localhost:8501 Wait 5 seconds Take snapshot Click element with ref from snapshot Wait for "Success" text Take screenshot ``` ### Responsive Testing ```sql Resize to 375x667 # Mobile Take screenshot Resize to 768x1024 # Tablet Take screenshot Resize to 1920x1080 # Desktop Take screenshot ``` ### Form Submission ```sql Fill form fields (batch) Click Submit Wait for success message Verify in snapshot ``` ### Error Checking ```sql Get console messages (onlyErrors=true) Get network requests Verify no 404s or 500s ``` --- ## Troubleshooting | Issue | Solution | | -------------------------- | ---------------------------------------------------------------------- | | Browsers not installed | Run `npx @playwright/mcp browser install` | | Element not found | Take snapshot first to get current page state and exact ref | | Tests too slow | Use `browser_fill_form` instead of multiple `browser_type` | | MCP not starting | Restart IDE, verify `mcp.json` is valid JSON | | Timeout errors | Increase wait times or use `browser_wait_for` with specific conditions | | Screenshots blank | Ensure page is fully loaded before taking screenshot | | Console errors not showing | Use `browser_console_messages` with `onlyErrors=true` parameter | --- ## Resources - `TESTING_PATTERNS.md` - Common test scenarios (coming soon) - `STREAMLIT_TESTING.md` - Streamlit-specific patterns (coming soon) - `ACCESSIBILITY.md` - Accessibility testing workflows (coming soon) - `mcp-config.json` - MCP server configuration
Quoted from sfc-gh-dflippo/snowflake-dbt-demo for reference β see the original for the authoritative, latest version.
π Full skill instructions β original source: sfc-gh-dflippo/snowflake-dbt-demo
How to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/playwright-mcp/ - Save the file as
SKILL.md - The agent will automatically discover the skill based on its description.
Option B: Global Installation (All Agents)
Save the file to these locations to make it available across all projects:
- Claude Code:
~/.claude/skills/sfc-gh-dflippo/snowflake-dbt-demo/playwright-mcp/SKILL.md - Cursor:
~/.cursor/skills/sfc-gh-dflippo/snowflake-dbt-demo/playwright-mcp/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/sfc-gh-dflippo/snowflake-dbt-demo/playwright-mcp/SKILL.md
π Install with CLI:npx skills add sfc-gh-dflippo/snowflake-dbt-demo