Agent skill

test-browser

Run browser tests on pages affected by current PR or branch

Stars 27
Forks 6

Install this agent skill to your Project

npx add-skill https://github.com/ratacat/claude-skills/tree/main/skills/test-browser

SKILL.md

Arguments

[PR number, branch name, or 'current' for current branch]

Browser Test Command

<command_purpose>Run end-to-end browser tests on pages affected by a PR or branch changes using agent-browser CLI.</command_purpose>

CRITICAL: Use agent-browser CLI Only

DO NOT use Chrome MCP tools (mcp__claude-in-chrome__*).

This command uses the agent-browser CLI exclusively. The agent-browser CLI is a Bash-based tool from Vercel that runs headless Chromium. It is NOT the same as Chrome browser automation via MCP.

If you find yourself calling mcp__claude-in-chrome__* tools, STOP. Use agent-browser Bash commands instead.

Introduction

QA Engineer specializing in browser-based end-to-end testing

This command tests affected pages in a real browser, catching issues that unit tests miss:

  • JavaScript integration bugs
  • CSS/layout regressions
  • User workflow breakages
  • Console errors

Prerequisites

Setup

Check installation:

bash
command -v agent-browser >/dev/null 2>&1 && echo "Installed" || echo "NOT INSTALLED"

Install if needed:

bash
npm install -g agent-browser
agent-browser install  # Downloads Chromium (~160MB)

See the agent-browser skill for detailed usage.

Main Tasks

0. Verify agent-browser Installation

Before starting ANY browser testing, verify agent-browser is installed:

bash
command -v agent-browser >/dev/null 2>&1 && echo "Ready" || (echo "Installing..." && npm install -g agent-browser && agent-browser install)

If installation fails, inform the user and stop.

1. Ask Browser Mode

<ask_browser_mode>

Before starting tests, ask user if they want to watch the browser:

Use AskUserQuestion with:

  • Question: "Do you want to watch the browser tests run?"
  • Options:
    1. Headed (watch) - Opens visible browser window so you can see tests run
    2. Headless (faster) - Runs in background, faster but invisible

Store the choice and use --headed flag when user selects "Headed".

</ask_browser_mode>

2. Determine Test Scope

<test_target> $ARGUMENTS </test_target>

<determine_scope>

If PR number provided:

bash
gh pr view [number] --json files -q '.files[].path'

If 'current' or empty:

bash
git diff --name-only main...HEAD

If branch name provided:

bash
git diff --name-only main...[branch]

</determine_scope>

3. Map Files to Routes

<file_to_route_mapping>

Map changed files to testable routes:

File Pattern Route(s)
app/views/users/* /users, /users/:id, /users/new
app/controllers/settings_controller.rb /settings
app/javascript/controllers/*_controller.js Pages using that Stimulus controller
app/components/*_component.rb Pages rendering that component
app/views/layouts/* All pages (test homepage at minimum)
app/assets/stylesheets/* Visual regression on key pages
app/helpers/*_helper.rb Pages using that helper
src/app/* (Next.js) Corresponding routes
src/components/* Pages using those components

Build a list of URLs to test based on the mapping.

</file_to_route_mapping>

4. Verify Server is Running

<check_server>

Before testing, verify the local server is accessible:

bash
agent-browser open http://localhost:3000
agent-browser snapshot -i

If server is not running, inform user:

markdown
**Server not running**

Please start your development server:
- Rails: `bin/dev` or `rails server`
- Node/Next.js: `npm run dev`

Then run `/test-browser` again.

</check_server>

5. Test Each Affected Page

<test_pages>

For each affected route, use agent-browser CLI commands (NOT Chrome MCP):

Step 1: Navigate and capture snapshot

bash
agent-browser open "http://localhost:3000/[route]"
agent-browser snapshot -i

Step 2: For headed mode (visual debugging)

bash
agent-browser --headed open "http://localhost:3000/[route]"
agent-browser --headed snapshot -i

Step 3: Verify key elements

  • Use agent-browser snapshot -i to get interactive elements with refs
  • Page title/heading present
  • Primary content rendered
  • No error messages visible
  • Forms have expected fields

Step 4: Test critical interactions

bash
agent-browser click @e1  # Use ref from snapshot
agent-browser snapshot -i

Step 5: Take screenshots

bash
agent-browser screenshot page-name.png
agent-browser screenshot --full page-name-full.png  # Full page

</test_pages>

6. Human Verification (When Required)

<human_verification>

Pause for human input when testing touches:

Flow Type What to Ask
OAuth "Please sign in with [provider] and confirm it works"
Email "Check your inbox for the test email and confirm receipt"
Payments "Complete a test purchase in sandbox mode"
SMS "Verify you received the SMS code"
External APIs "Confirm the [service] integration is working"

Use AskUserQuestion:

markdown
**Human Verification Needed**

This test touches the [flow type]. Please:
1. [Action to take]
2. [What to verify]

Did it work correctly?
1. Yes - continue testing
2. No - describe the issue

</human_verification>

7. Handle Failures

<failure_handling>

When a test fails:

  1. Document the failure:

    • Screenshot the error state: agent-browser screenshot error.png
    • Note the exact reproduction steps
  2. Ask user how to proceed:

    markdown
    **Test Failed: [route]**
    
    Issue: [description]
    Console errors: [if any]
    
    How to proceed?
    1. Fix now - I'll help debug and fix
    2. Create todo - Add to todos/ for later
    3. Skip - Continue testing other pages
    
  3. If "Fix now":

    • Investigate the issue
    • Propose a fix
    • Apply fix
    • Re-run the failing test
  4. If "Create todo":

    • Create {id}-pending-p1-browser-test-{description}.md
    • Continue testing
  5. If "Skip":

    • Log as skipped
    • Continue testing

</failure_handling>

8. Test Summary

<test_summary>

After all tests complete, present summary:

markdown
## Browser Test Results

**Test Scope:** PR #[number] / [branch name]
**Server:** http://localhost:3000

### Pages Tested: [count]

| Route | Status | Notes |
|-------|--------|-------|
| `/users` | Pass | |
| `/settings` | Pass | |
| `/dashboard` | Fail | Console error: [msg] |
| `/checkout` | Skip | Requires payment credentials |

### Console Errors: [count]
- [List any errors found]

### Human Verifications: [count]
- OAuth flow: Confirmed
- Email delivery: Confirmed

### Failures: [count]
- `/dashboard` - [issue description]

### Created Todos: [count]
- `005-pending-p1-browser-test-dashboard-error.md`

### Result: [PASS / FAIL / PARTIAL]

</test_summary>

Quick Usage Examples

bash
# Test current branch changes
/test-browser

# Test specific PR
/test-browser 847

# Test specific branch
/test-browser feature/new-dashboard

agent-browser CLI Reference

ALWAYS use these Bash commands. NEVER use mcp__claude-in-chrome__ tools.*

bash
# Navigation
agent-browser open <url>           # Navigate to URL
agent-browser back                 # Go back
agent-browser close                # Close browser

# Snapshots (get element refs)
agent-browser snapshot -i          # Interactive elements with refs (@e1, @e2, etc.)
agent-browser snapshot -i --json   # JSON output

# Interactions (use refs from snapshot)
agent-browser click @e1            # Click element
agent-browser fill @e1 "text"      # Fill input
agent-browser type @e1 "text"      # Type without clearing
agent-browser press Enter          # Press key

# Screenshots
agent-browser screenshot out.png       # Viewport screenshot
agent-browser screenshot --full out.png # Full page screenshot

# Headed mode (visible browser)
agent-browser --headed open <url>      # Open with visible browser
agent-browser --headed click @e1       # Click in visible browser

# Wait
agent-browser wait @e1             # Wait for element
agent-browser wait 2000            # Wait milliseconds

Expand your agent's capabilities with these related and highly-rated skills.

ratacat/claude-skills

brave-search

Use when user asks to search the web, look something up online, find current/recent/latest information, or needs cited answers. Triggers on "search", "look up", "find out about", "what is the current/latest", image searches, news lookups. NOT for searching code/files—only for web/internet searches.

27 6
Explore
ratacat/claude-skills

bug-reproduction-validator

Use this agent when you receive a bug report or issue description and need to verify whether the reported behavior is actually a bug. This agent will attempt to reproduce the issue systematically, validate the steps to reproduce, and confirm whether the behavior deviates from expected functionality. <example>\nContext: The user has reported a potential bug in the application.\nuser: "Users are reporting that the email processing fails when there are special characters in the subject line"\nassistant: "I'll use the bug-reproduction-validator agent to verify if this is an actual bug by attempting to reproduce it"\n<commentary>\nSince there's a bug report about email processing with special characters, use the bug-reproduction-validator agent to systematically reproduce and validate the issue.\n</commentary>\n</example>\n<example>\nContext: An issue has been raised about unexpected behavior.\nuser: "There's a report that the brief summary isn't including all emails from today"\nassistant: "Let me launch the b...

27 6
Explore
ratacat/claude-skills

agent-native-audit

Run comprehensive agent-native architecture review with scored principles

27 6
Explore
ratacat/claude-skills

brainstorming

This skill should be used before implementing features, building components, or making changes. It guides exploring user intent, approaches, and design decisions before planning. Triggers on "let's brainstorm", "help me think through", "what should we build", "explore approaches", ambiguous feature requests, or when the user's request has multiple valid interpretations that need clarification.

27 6
Explore
ratacat/claude-skills

performance-oracle

Use this agent when you need to analyze code for performance issues, optimize algorithms, identify bottlenecks, or ensure scalability. This includes reviewing database queries, memory usage, caching strategies, and overall system performance. The agent should be invoked after implementing features or when performance concerns arise.\n\n<example>\nContext: The user has just implemented a new feature that processes user data.\nuser: "I've implemented the user analytics feature. Can you check if it will scale?"\nassistant: "I'll use the performance-oracle agent to analyze the scalability and performance characteristics of your implementation."\n<commentary>\nSince the user is concerned about scalability, use the Task tool to launch the performance-oracle agent to analyze the code for performance issues.\n</commentary>\n</example>\n\n<example>\nContext: The user is experiencing slow API responses.\nuser: "The API endpoint for fetching reports is taking over 2 seconds to respond"\nassistant: "Let me invoke the...

27 6
Explore
ratacat/claude-skills

triage

Triage and categorize findings for the CLI todo system

27 6
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results