Community研究与数据分析github.com

ComposioHQ/webapp-testing

用于与本地Web应用交互和测试的工具包,基于Playwright。支持验证前端功能、调试UI行为、捕获浏览器截图和查看浏览器日志。

webapp-testing 是什么?

Web应用测试技能(ComposioHQ/webapp-testing)为AI代理提供了一个基于Playwright的完整框架,用于测试和调试本地Web应用。该技能的核心价值在于简化动态Web应用的交互测试流程,特别适合处理现代前端框架(如React、Vue)构建的应用。它支持多种平台(包括Claude Code、Cursor等),通过提供辅助脚本和决策树指导代理选择最佳测试策略。主要功能包括:使用`scripts/with_server.py`自动管理服务器生命周期(支持单服务器或多服务器组合)、通过“侦察-行动”模式逐步识别DOM选择器并执行操作、以及捕获浏览器截图和控制台日志。该技能强调将辅助脚本作为黑盒使用,避免直接读取源代码以节省上下文窗口。最佳实践包括始终等待`networkidle`状态后再检查DOM、使用同步Playwright脚本、以及利用描述性选择器(如`text=`、`role=`)进行精确元素定位。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComposioHQ/awesome-codex-skills/tree/main/webapp-testing

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · 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 20 individual skills — each has its own dedicated page.

ComposioHQ/-21risk-automation

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/-2chat-automation

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/ably-automation

Automate Ably tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abstract-automation

Automate Abstract tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abuselpdb-automation

Automate Abuselpdb tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abyssale-automation

Automate Abyssale tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accelo-automation

Automate Accelo tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accredible-certificates-automation

Automate Accredible Certificates tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/acculynx-automation

Automate Acculynx tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/active-campaign-automation

Automate ActiveCampaign tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/addresszen-automation

Automate Addresszen tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adobe-automation

Automate Adobe tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adrapid-automation

Automate Adrapid tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adyntel-automation

Automate Adyntel tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aeroleads-automation

Automate Aeroleads tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aero-workflow-automation

Automate Aero Workflow tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinda-automation

Automate Affinda tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinity-automation

Automate Affinity tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agencyzoom-automation

Automate Agencyzoom tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agent-deep-links

Build, validate, and troubleshoot deep links for Codex, Cursor, VS Code, Visual Studio, and similar tools. Use when users ask for clickable links (especially in Slack) that open threads, files, folders, or app settings.

相关技能