闲社服务运行正常AI智能体自动化平台
w

Web应用测试

技能标识:webapp-testing

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.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

Web应用测试

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,然后使用辅助脚本:

单服务器:
bash
python scripts/withserver.py --server npm run dev --port 5173 -- python yourautomation.py

多服务器(例如,后端 + 前端):
bash
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 逻辑(服务器自动管理):
python
from playwright.syncapi import syncplaywright

with sync_playwright() as p:
browser = p.chromium.launch(headless=True) # 始终以无头模式启动 chromium
page = browser.new_page()
page.goto(http://localhost:5173) # 服务器已运行并准备就绪
page.waitforload_state(networkidle) # 关键:等待 JS 执行
# ... 你的自动化逻辑
browser.close()

侦察-行动模式

  1. 1. 检查渲染后的 DOM:
python page.screenshot(path=/tmp/inspect.png, full_page=True) content = page.content() page.locator(button).all()
  1. 2. 从检查结果中识别选择器
  1. 3. 使用发现的选择器执行操作

常见陷阱

❌ 不要 在等待 networkidle 之前检查动态应用的 DOM
✅ 应该 在检查之前等待 page.waitforload_state(networkidle)

最佳实践

  • - 将捆绑脚本作为黑盒使用 - 要完成任务,请考虑 scripts/ 中是否有可用的脚本。这些脚本可靠地处理常见、复杂的工作流程,而不会污染上下文窗口。使用 --help 查看用法,然后直接调用。
  • 使用 syncplaywright() 编写同步脚本
  • 完成后始终关闭浏览器
  • 使用描述性选择器:text=、role=、CSS 选择器或 ID
  • 添加适当的等待:page.waitforselector() 或 page.waitfor_timeout()

参考文件

  • - examples/ - 展示常见模式的示例:
- element_discovery.py - 发现页面上的按钮、链接和输入框 - statichtmlautomation.py - 使用 file:// URL 处理本地 HTML - console_logging.py - 在自动化过程中捕获控制台日志

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 webapp-testing-anthropic-1776087138 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 webapp-testing-anthropic-1776087138 技能

通过命令行安装

skillhub install webapp-testing-anthropic-1776087138

下载

⬇ 下载 webapp-testing v1.0.0(免费)

文件大小: 10.03 KB | 发布时间: 2026-4-15 14:55

v1.0.0 最新 2026-4-15 14:55
Initial release of webapp-testing: tools and best practices for Playwright-based local web application testing.

- Provides helper scripts for managing server lifecycles, including support for multiple servers
- Includes a decision tree for selecting the right testing approach for static or dynamic web apps
- Documents reconnaissance-then-action pattern for effective UI inspection and automation
- Offers usage examples and best practices for robust Playwright scripting
- Bundles reference scripts and sample automation patterns in the examples directory
返回顶部