Official程式設計與開發github.com

webapp-testing

用於使用 Playwright 與本機 Web 應用程式互動及測試的工具組。支援驗證前端功能、偵錯 UI 行為、擷取瀏覽器螢幕截圖及檢視瀏覽器日誌。

webapp-testing 是什麼?

此技能為開發者提供一個完整的工具組,以使用 Playwright 對本機 Web 應用程式進行自動化測試。它能協助驗證前端功能、偵錯 UI 行為、擷取瀏覽器螢幕截圖以及檢視瀏覽器日誌,從而簡化測試流程。決策樹指引使用者根據應用程式的類型(靜態 HTML 或動態 Web 應用程式)選擇合適的方法,而「偵察後行動」模式則簡化了在動態應用程式中定位元素的過程。此技能支援同步的 Playwright 腳本,並包含輔助腳本來管理伺服器生命週期,例如 `with_server.py`,可在啟動測試前自動啟動與停止伺服器。關鍵的最佳實務包括在檢查 DOM 前等待 `networkidle` 載入狀態、使用描述性的定位器,以及將腳本作為黑箱工具直接呼叫,以避免用不必要的程式碼污染工作階段。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/anthropics/skills/tree/main/skills/webapp-testing

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Web 應用程式測試

若要測試本機 Web 應用程式,請撰寫原生的 Python Playwright 腳本。

可用的輔助腳本:

  • scripts/with_server.py - 管理伺服器生命週期(支援多個伺服器)

請務必先以 --help 執行腳本 以了解用法。除非您嘗試執行腳本後發現確實需要客製化解決方案,否則請勿閱讀原始碼。這些腳本可能非常龐大,因此會污染您的對話環境。它們是設計為直接以黑箱方式呼叫,而非嵌入到您的對話環境中。

決策樹:選擇您的方法

使用者任務 → 是否為靜態 HTML?
    ├─ 是 → 直接讀取 HTML 檔案以識別選擇器
    │         ├─ 成功 → 使用選擇器撰寫 Playwright 腳本
    │         └─ 失敗/不完整 → 視為動態(如下)
    │
    └─ 否(動態 Web 應用程式)→ 伺服器是否已在執行?
        ├─ 否 → 執行:python scripts/with_server.py --help
        │        然後使用輔助腳本並撰寫簡化的 Playwright 腳本
        │
        └─ 是 → 偵察後行動模式:
            1. 導航並等待 networkidle
            2. 擷取螢幕截圖或檢查 DOM
            3. 從渲染狀態識別選擇器
            4. 使用發現的選擇器執行動作

範例:使用 with_server.py

要啟動伺服器,請先執行 --help,然後使用輔助腳本:

單一伺服器:

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

多個伺服器(例如後端 + 前端):

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

若要建立自動化腳本,僅需包含 Playwright 邏輯(伺服器會自動管理):

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True) # 務必以無頭模式啟動 Chromium
    page = browser.new_page()
    page.goto('http://localhost:5173') # 伺服器已在執行且就緒
    page.wait_for_load_state('networkidle') # 關鍵:等待 JavaScript 執行
    # ... 您的自動化邏輯
    browser.close()

偵察後行動模式

  1. 檢查渲染後的 DOM:

    page.screenshot(path='/tmp/inspect.png', full_page=True)
    content = page.content()
    page.locator('button').all()
    
  2. 從檢查結果中識別選擇器

  3. 使用發現的選擇器執行動作

常見陷阱

❌ 請勿 在動態應用程式上等待 networkidle 之前檢查 DOM ✅ 請務必 在檢查前等待 page.wait_for_load_state('networkidle')

最佳實務

  • 將綑綁的腳本視為黑箱使用 - 若要完成任務,請考慮 scripts/ 中的腳本是否能提供協助。這些腳本可以可靠地處理常見的複雜工作流程,而不會佔用對話環境。使用 --help 查看用法,然後直接呼叫。
  • 使用 sync_playwright() 來編寫同步腳本
  • 完成後務必關閉瀏覽器
  • 使用描述性選擇器:text=、role=、CSS 選擇器或 ID
  • 加入適當的等待:page.wait_for_selector() 或 page.wait_for_timeout()

參考檔案

  • examples/ - 展示常見模式的範例:
    • element_discovery.py - 探索頁面上的按鈕、連結和輸入框
    • static_html_automation.py - 使用 file:// URL 處理本機 HTML
    • console_logging.py - 自動化過程中擷取主控台日誌

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

academy-guide

Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.

algorithmic-art

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists

anthropics/template-skill

Replace with description of the skill and when Claude should use it.

brand-guidelines

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists

claude-api

|-

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of

frontend-design

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

internal-comms

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

pptx

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \

skill-creator

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill

slack-gif-creator

Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like

theme-factory

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

web-artifacts-builder

Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.

xlsx

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \

相關技能