webapp-testing
它能做什么
这个工具可以帮你测试你在电脑上开发的网站。你可以用它检查网站功能是否正常、给屏幕“拍照”(截图),还能查看出现的错误信息。
适用场景
- ✓当你想确认网站上的某个按钮能否正常使用时。
- ✓当你想截一张网站页面外观的截图时。
- ✓当你想检查网站上是否出现错误时。
技能链接
https://github.com/anthropics/skills/blob/main/skills/webapp-testing/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我检查个人资料页面上的“保存”按钮是否正常工作,并截一张图。”
每周 5 个新技能,1 分钟读完。
工作原理
你需要写一个简短的 Python 程序,让它调用这个工具打开你的网站、进行操作,并检查结果是否符合预期。它甚至可以帮你启动网站的服务器。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
Inspect rendered DOM:
page.screenshot(path='/tmp/inspect.png', full_page=True) content = page.content() page.locator('button').all()Identify selectors from inspection results
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--helpto 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()orpage.wait_for_timeout()
Reference Files
- examples/ - Examples showing common patterns:
element_discovery.py- Discovering buttons, links, and inputs on a pagestatic_html_automation.py- Using file:// URLs for local HTMLconsole_logging.py- Capturing console logs during automation
常见问题
什么是“headless”?
“headless”的意思是浏览器在后台运行,不会在屏幕上弹出窗口,用来自动完成任务。
为什么要等待 networkidle?
这样可以确保网站已经加载完所有内容和动画,之后再进行操作或检查,结果会更准确。
什么是“选择器”(selectors)?
选择器就像地址,工具靠它们找到网站上特定的按钮、文字或输入框。
详情
作者的原始描述
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
repo: anthropics/skills
热度
- GitHub 星标
- 181k
- 排名
- #652
- 许可证
- —
- 更新时间
- 2026/10/9
评论
- …
同一仓库的更多技能
academy-guide
181k让你的智能体推荐学习 Claude 的课程和教程。当你对如何使用 Claude 或其相关产品有疑问时很有用。
algorithmic-art
181k帮助你的智能体用代码创作艺术,生成独特的图像。适合你想要原创计算机生成艺术的时候。
brand-guidelines
181k让你的智能体将 Anthropic 的品牌色和视觉风格应用到各类素材上。适用于在不同项目中保持公司视觉形象的统一。
canvas-design
181k帮助你的智能体在文件中创作精美的视觉艺术作品。当你需要海报、艺术图或任何静态设计时很有用。