webapp-testing
它能做什么
这个工具可以帮你测试你在电脑上开发的网站。你可以检查网站功能是否符合预期、为页面拍“截图”,还能查看错误信息。
适用场景
- ✓当你想确认网站上的某个按钮能否正常工作时。
- ✓当你想为网站的外观拍一张“照片”时。
- ✓当你想检查网站的错误提示是否正确显示时。
技能链接
https://github.com/ComposioHQ/awesome-claude-skills/blob/master/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”是什么意思?
意思是浏览器在运行时不会在屏幕上显示窗口,而是在后台运行,因此速度更快。
为什么要等待“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.
热度
- GitHub 星标
- 77k
- 排名
- #2610
- 许可证
- —
- 更新时间
- 2026/9/18
评论
- …
同一仓库的更多技能
artifacts-builder
77k帮助你的智能体构建复杂的用户界面。它借助现代技术,创建功能丰富的交互式网页。
brand-guidelines
77k帮助你的智能体把官方品牌色和字体应用到各类材料中。适合需要体现公司视觉形象的场景,保持视觉统一。
canvas-design
77k让你的智能体创作 .png 和 .pdf 格式的原创视觉作品。当用户需要海报、艺术作品或其他静态设计时使用。
changelog-generator
77k帮助你的智能体根据代码提交记录撰写面向用户的更新说明。它能把技术内容转换成通俗易懂的文字。