Community研究與資料分析github.com

ComposioHQ/webapp-testing

用於與本機網頁應用程式互動和測試的工具組,基於 Playwright。支援驗證前端功能、除錯 UI 行為、擷取瀏覽器螢幕截圖,以及檢視瀏覽器記錄。

webapp-testing 是什麼?

此技能提供一個完整的工具組,用於測試本機網頁應用程式,主要利用 Playwright 撰寫 Python 腳本。它包含輔助腳本(如 `scripts/with_server.py`)來自動管理伺服器生命週期,並支援單一或多個伺服器(例如前端 + 後端)的啟動與關閉。核心工作流程採用「偵察後行動」模式:先導航至目標頁面並等待 `networkidle`,然後透過螢幕截圖或檢視 DOM 來辨識選擇器,最後再執行實際操作。此舉能有效避免因動態內容尚未載入而導致選擇器失效的常見錯誤。技能支援主要代理平台(如 Claude Code、Cursor 等)在命令行環境中執行。它的設計強調將輔助腳本視為黑盒子直接呼叫,以節省上下文視窗,並內建最佳實務,例如使用同步 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 的新對話。

說明文件

網頁應用程式測試

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

可用輔助腳本:

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

務必先以 --help 執行腳本,以瞭解使用方式。在嘗試執行腳本並發現確實需要自訂解決方案之前,請勿閱讀原始碼。這些腳本可能非常龐大,因此會污染你的上下文視窗。它們存在的目的是作為黑盒子腳本直接呼叫,而非被納入你的上下文視窗。

決策樹:選擇你的方法

使用者任務 → 是否為靜態 HTML?
    ├─ 是 → 直接讀取 HTML 檔案以識別選擇器
    │         ├─ 成功 → 使用選擇器撰寫 Playwright 腳本
    │         └─ 失敗/不完整 → 視為動態(見下方)
    │
    └─ 否(動態網頁應用程式)→ 伺服器是否已在執行?
        ├─ 否 → 執行: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.

相關技能