AgentSkillsCN

browser-max-automation

使用 Playwright MCP 进行浏览器自动化,适用于 Web 测试、UI 验证与表单自动化。当您需要浏览网站、点击元素、填写表单、截取屏幕截图,或测试 Web 应用程序时,可使用此技能。支持 iframe 操作与复杂的 JavaScript 执行。

SKILL.md
--- frontmatter
name: browser-max-automation
description: Browser automation using Playwright MCP for web testing, UI verification, and form automation. Use when navigating websites, clicking elements, filling forms, taking screenshots, or testing web applications. Supports iframe operations and complex JavaScript execution.
license: Complete terms in LICENSE.txt
metadata:
  author: yamapan (https://github.com/aktsmm)

Browser Max Automation

Browser automation via Playwright MCP.

When to use

  • Automating browser-based workflows or QA checks
  • Verifying UI states, DOM changes, or visual regressions
  • Filling forms, clicking elements, or capturing screenshots

Prerequisites

Configure .vscode/mcp.json:

json
{
  "servers": {
    "playwright": {
      "command": "npx",
      "args": ["@anthropic-ai/mcp-playwright@latest", "--browser", "chrome"]
    }
  }
}

Quick Reference

CommandPurpose
browser_navigateOpen URL
browser_snapshotGet element refs (accessibility tree)
browser_clickClick element by ref
browser_typeInput text
browser_take_screenshotCapture screen
browser_wait_forWait for text/time
browser_run_codeExecute JavaScript

Basic Workflow

code
1. browser_navigate(url)
2. browser_snapshot → get ref
3. browser_click/type(ref)
4. browser_snapshot → verify

Commands

Navigate

code
mcp_playwright_browser_navigate
  url: "https://example.com"

Snapshot

code
mcp_playwright_browser_snapshot

Returns accessibility tree with ref values for each element.

Click

code
mcp_playwright_browser_click
  element: "Submit button"
  ref: "f2e123"

Type

code
mcp_playwright_browser_type
  element: "Username"
  ref: "f2e456"
  text: "user@example.com"
  submit: true  # Press Enter

Screenshot

code
mcp_playwright_browser_take_screenshot
  filename: "result.png"

Wait

code
mcp_playwright_browser_wait_for
  text: "Loading complete"  # or
  time: 3

Tabs

code
mcp_playwright_browser_tabs
  action: "list" | "new" | "close" | "select"
  index: 0

Advanced

iframe Operations

javascript
async (page) => {
  const frame1 = page.locator('iframe[name="Content"]').contentFrame();
  const frame2 = frame1.locator('iframe[title="Player"]').contentFrame();
  await frame2.getByRole("radio", { name: "Option A" }).click({ force: true });
  return "Selected";
};

force: true

Use when element is covered by another (e.g., SVG overlay):

javascript
await element.click({ force: true });

When browser_run_code is disabled

Use snapshot + click instead:

code
browser_snapshot → get ref → browser_click(ref)

Reference

TypeUse CaseSelection
radioSingle choiceOne only
checkboxMultiple choice0 to many