Webapp Testing

作者: Anthropic

使用 Playwright 與本地網頁應用程式互動及測試的工具包。支援驗證前端功能、除錯 UI 行為、擷取瀏覽器螢幕截圖,以及檢視瀏覽器日誌。 授權條款:完整條款請見 LICENSE.txt

npx skills add https://github.com/anthropics/skills --skill webapp-testing

Web Application Testing

To test local web applications, write native Python Playwright scripts.

Helper Scripts Available:

  • scripts/with_server.py - Manages server lifecycle (supports multiple servers)

Always run scripts with --help first to see usage. DO NOT read the source until you try running the script first and find that a customized solution is abslutely necessary. These scripts can be very large and thus pollute your context window. They exist to be called directly as black-box scripts rather than ingested into your context window.

Decision Tree: Choosing Your Approach

User task → Is it static HTML?
    ├─ Yes → Read HTML file directly to identify selectors
    │         ├─ Success → Write Playwright script using selectors
    │         └─ Fails/Incomplete → Treat as dynamic (below)
    │
    └─ No (dynamic webapp) → Is the server already running?
        ├─ No → Run: python scripts/with_server.py --help
        │        Then use the helper + write simplified Playwright script
        │
        └─ Yes → Reconnaissance-then-action:
            1. Navigate and wait for networkidle
            2. Take screenshot or inspect DOM
            3. Identify selectors from rendered state
            4. Execute actions with discovered selectors

Example: Using with_server.py

To start a server, run --help first, then use the helper:

Single server:

python scripts/with_server.py --server "npm run dev" --port 5173 -- python your_automation.py

Multiple servers (e.g., backend + frontend):

python scripts/with_server.py \
  --server "cd backend && python server.py" --port 3000 \
  --server "cd frontend && npm run dev" --port 5173 \
  -- python your_automation.py

To create an automation script, include only Playwright logic (servers are managed automatically):

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True) # Always launch chromium in headless mode
    page = browser.new_page()
    page.goto('http://localhost:5173') # Server already running and ready
    page.wait_for_load_state('networkidle') # CRITICAL: Wait for JS to execute
    # ... your automation logic
    browser.close()

Reconnaissance-Then-Action Pattern

  1. Inspect rendered DOM:

    page.screenshot(path='/tmp/inspect.png', full_page=True)
    content = page.content()
    page.locator('button').all()
    
  2. Identify selectors from inspection results

  3. Execute actions using discovered selectors

Common Pitfall

Don't inspect the DOM before waiting for networkidle on dynamic apps ✅ Do wait for page.wait_for_load_state('networkidle') before inspection

Best Practices

  • Use bundled scripts as black boxes - To accomplish a task, consider whether one of the scripts available in scripts/ can help. These scripts handle common, complex workflows reliably without cluttering the context window. Use --help to see usage, then invoke directly.
  • Use sync_playwright() for synchronous scripts
  • Always close the browser when done
  • Use descriptive selectors: text=, role=, CSS selectors, or IDs
  • Add appropriate waits: page.wait_for_selector() or page.wait_for_timeout()

Reference Files

  • examples/ - Examples showing common patterns:
    • element_discovery.py - Discovering buttons, links, and inputs on a page
    • static_html_automation.py - Using file:// URLs for local HTML
    • console_logging.py - Capturing console logs during automation

來自 Anthropic 的更多技能

Algorithmic Art
Anthropic
使用p5.js建立演算法藝術,包含種子隨機性與互動式參數探索。當使用者要求以程式碼創作藝術、生成式藝術、演算法藝術、流場或粒子系統時使用此功能。創作原創演算法藝術,避免抄襲現有藝術家作品以規避版權問題。 授權:完整條款請見LICENSE.txt
creative
Internal Comms
Anthropic
一套資源,幫助我撰寫各種內部溝通內容,使用公司偏好的格式。每當需要撰寫內部溝通文件(如狀態報告、領導層更新、第三方更新、公司通訊、常見問題、事件報告、專案更新等)時,Claude 應使用此技能。 授權:完整條款請見 LICENSE.txt
Artifacts Builder
Anthropic
用於創建精緻、多組件 claude.ai HTML 工件的一套工具,採用現代前端網頁技術(React、Tailwind CSS、shadcn/ui)。適用於需要狀態管理、路由或 shadcn/ui 元件的複雜工件,不適用於簡單的單一檔案 HTML/JSX 工件。 授權條款:完整條款請見 LICENSE.txt
development
XLSX
Anthropic
全面的試算表建立、編輯與分析,支援公式、格式設定、資料分析與視覺化。當 Claude 需要處理試算表(.xlsx、.xlsm、.csv、.tsv 等)以進行:(1) 建立含公式與格式的新試算表,(2) 讀取或分析資料,(3) 修改現有試算表並保留公式,(4) 試算表中的資料分析與視覺化,或 (5) 重新計算公式。 授權:專有。LICENSE.txt 包含完整條款。
document
Skill Creator
Anthropic
建立有效技能的指南。當使用者想要建立新技能(或更新現有技能)以擴展 Claude 的專業知識、工作流程或工具整合能力時,應使用此技能。 授權:完整條款請見 LICENSE.txt
Slack Gif Creator
Anthropic
用於建立針對 Slack 最佳化的動畫 GIF 工具包,包含尺寸限制驗證器與可組合的動畫基本元件。當使用者要求為 Slack 製作動畫 GIF 或表情動畫(例如「幫我做一個 X 做 Y 的 Slack GIF」)時,此技能便會啟用。 授權條款:完整條款請見 LICENSE.txt
creative
Theme Factory
Anthropic
用於為成品套用主題風格的工具包。這些成品可以是投影片、文件、報告、HTML登陸頁面等。內建10組預設主題(含配色與字型),可套用於任何已建立的成品,或即時生成全新主題。 授權條款:完整條款請見LICENSE.txt
creative
Brand Guidelines
Anthropic
將Anthropic官方品牌色彩與字體應用於任何可能需要呈現Anthropic風格與視覺感受的成品。當涉及品牌色彩、風格指南、視覺格式或公司設計標準時使用此規範。 授權:完整條款請見LICENSE.txt
creative