Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计提醒

testing-browser测试浏览器

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

235

周安装

10

GitHub Stars

4

下载量

82
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:testing-browser(测试浏览器)
来源仓库:https://github.com/riccardogrin/skills
仓库路径:skills/testing-browser
安装命令:
npx skills add https://github.com/riccardogrin/skills --skill testing-browser
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/riccardogrin/skills --skill testing-browser

简介

用于前端功能的自动化交互与行为验证。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

  • 适合模拟用户操作、检查 DOM 状态和捕获异常。
  • 支持主流浏览器的兼容性测试和性能监控。
  • 涉及真实页面时应注意隔离测试环境与生产流量。
  • testing-browser 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Testing Browser

Verify web UI behavior with Playwright — start servers, take screenshots, inspect accessibility trees, and run assertions. Self-contained scripts, no MCP dependency. Designed for loop agent VERIFY phases but works standalone.

Reference Files

FileRead When
references/assertion-patterns.mdChoosing assertions for a specific framework or UI pattern

Prerequisites

Playwright must be installed:

pip install playwright && python -m playwright install chromium

All scripts use only Playwright + Python standard library.

Note: Use python -m playwright instead of bare playwright — pip user installs may not add the script to PATH.

Scripts

ScriptPurposeQuick Example
scripts/verify.pyPass/fail assertions against a URLpython verify.py URL --assert "text:Welcome"
scripts/interact.pyMulti-step browser flows (click, fill, assert)python interact.py URL --fill "#email=test@test.com" --click "#submit" --assert "text:Welcome"
scripts/snapshot.pyAccessibility tree snapshot (LLM-friendly)python snapshot.py URL --wait-for "h1"
scripts/screenshot.pyScreenshot + accessibility tree + console errorspython screenshot.py URL --wait-for "h1"
scripts/with_server.pyServer lifecycle wrapperpython with_server.py --cmd "npm start" --port 3000 -- CMD

Common flags (all scripts except with_server.py)

FlagPurpose
--viewport WIDTHxHEIGHTSet viewport size (e.g., --viewport 375x812)
--device NAMEUse a Playwright device preset (e.g., --device "iPhone 14")
--dismiss-dialogsSilently dismiss JS dialogs (default: auto-dismiss with stderr warning)
--timeout MSNavigation/action timeout (default: 10000)
--use-chromeLaunch real Chrome with persistent profile — sessions survive restarts (see below)
--chrome-port PORTConnect to running Chrome via CDP (less reliable than --use-chrome)
--consolePrint detailed console log with timestamps, source locations, and stack traces

Key Concept: --wait-for vs --selector

Most web apps (React, Next.js, Vue, SPA frameworks) render content with client-side JavaScript after the initial page load. Without waiting, screenshots and snapshots capture a blank or partially-rendered page.

FlagPurposeAffects what is captured?
--wait-for SELECTORPauses until the element is visible, confirming JS has renderedNo — full page is still captured
--selector SELECTORScopes both the capture and accessibility tree to this elementYes — only that element is captured

Default to including --wait-for with screenshot.py and snapshot.py. It is harmless on static sites and essential for SPAs. Pick a stable element that only appears after the page renders (e.g., h1, main, nav, [data-testid=app]).

verify.py also supports --wait-for for cases where you need to wait before running assertions (e.g., SPAs, network-dependent content). Its text: and visible: assertions already wait up to 5s internally, so --wait-for is only needed for other wait conditions like network-idle or waiting for a specific selector before running non-waiting assertions.

You can combine both flags: --wait-for "h1" --selector "main" waits for h1 to appear, then captures only the main element.

Using Real Chrome (--use-chrome)

All scripts support --use-chrome to launch a real, visible Chrome window instead of headless Chromium. Uses a persistent .browser-data/ profile in the current working directory — sessions (cookies, localStorage) survive across runs.

How it works

# First run: fresh profile, opens visible Chrome
python verify.py http://localhost:3000 --use-chrome --assert "text:Welcome"

# Subsequent runs: session restored (cookies, login state preserved)
python verify.py http://localhost:3000 --use-chrome --assert "text:Dashboard"
  • The script launches Chrome, navigates to the URL, runs assertions, and closes Chrome
  • Profile data is saved to .browser-data/ in the current working directory
  • Add .browser-data/ to your .gitignore

Authenticated pages

On first run, the profile is fresh (not logged in). To establish a session:

# Script the login flow — session is saved for future runs
python interact.py http://localhost:3000/login --use-chrome \
    --fill "input[name=email]=test@test.com" \
    --fill "input[name=password]=password" \
    --click "button[type=submit]" \
    --wait "text:Dashboard" \
    --assert "text:Welcome"

# Now all future --use-chrome runs have the session
python verify.py http://localhost:3000/dashboard --use-chrome --assert "text:Dashboard"

Limitations

  • --device is ignored (can't change device emulation on real Chrome)
  • --viewport still works
  • Uses a separate profile from your daily Chrome — your bookmarks/extensions/accounts are not shared
  • Does not require closing your regular Chrome first

CDP alternative (--chrome-port)

--chrome-port PORT connects to an already-running Chrome via CDP. This is less reliable (requires Chrome to be started with --remote-debugging-port, background processes often interfere). Prefer --use-chrome unless you have a specific reason to use CDP. Both flags fall back to fresh Chromium on failure.

Enhanced Console Output (--console)

All scripts capture console messages and uncaught page errors. The --console flag enables detailed output:

<console-log count="5">
  [0.123s] [log] App initialized @ localhost:3000/main.js:42:10
  [0.456s] [warn] Deprecated API used @ localhost:3000/api.js:15:3
  [0.789s] [error] Failed to fetch user data @ localhost:3000/store.js:88:5
</console-log>

<page-errors count="1">
  [1.234s] TypeError: Cannot read properties of undefined (reading 'name')
    at UserProfile (localhost:3000/components/UserProfile.js:23:15)
    at renderWithHooks (localhost:3000/node_modules/react-dom/...)
</page-errors>

Without --console: only console errors and uncaught page errors are shown.

With --console: all messages (log, warn, error, info, debug) are shown with:

  • Timestamps relative to page load (e.g., [0.123s])
  • Source locations (file:line:col)
  • Uncaught exceptions with full stack traces (always shown, even without --console)

Use --console when debugging issues -- the timestamps help correlate events and the source locations point directly to problematic code.

Workflow

- [ ] Phase 1: Detect what to test
- [ ] Phase 2: Ensure Playwright is available
- [ ] Phase 3: Choose verification approach
- [ ] Phase 4: Write and run verification
- [ ] Phase 5: Integrate with loops (optional)

Phase 1: Detect What to Test

Scan the project for:

  • Web framework and dev server command (package.json scripts, manage.py runserver, etc.)
  • Port the dev server uses (read from config or framework defaults)
  • Key pages to verify (routes, entry points)
  • Existing test infrastructure (Playwright already configured? Cypress? Vitest browser mode?)

If Playwright is already configured: use the existing setup. Don't duplicate or conflict.

Phase 2: Ensure Playwright is Available

Check and install if needed:

python -c "from playwright.sync_api import sync_playwright; print('OK')" 2>/dev/null || \
    (pip install playwright && python -m playwright install chromium)

Phase 3: Choose Verification Approach

ScenarioScriptWhen
Quick pass/fail checkverify.pyVERIFY phases, smoke tests
Multi-step flows (login, forms, navigation)interact.pyClick, fill, assert in sequence
Debugging layout/contentsnapshot.pyInvestigating what the page contains
Visual verification, bug reportsscreenshot.pyNeed to see the page, full diagnostic dump
Complex/custom flowsCustom Playwright scriptWhen interact.py actions aren't enough

For loop agent VERIFY phases, verify.py (single page) or interact.py (multi-step) are the primary tools.

Phase 4: Write and Run Verification

verify.py (most common)

# Server already running
python verify.py http://localhost:3000 --assert "text:Welcome" --assert "no-console-errors"

# With server lifecycle
python with_server.py --cmd "npm start" --port 3000 -- \
    python verify.py http://localhost:3000 --assert "text:Welcome" --assert "no-console-errors"

Available assertions (used by both verify.py and interact.py):

AssertionChecks
text:EXPECTEDPage contains visible text (waits up to 5s)
no-text:UNEXPECTEDPage does NOT contain text
title:EXPECTEDPage title contains substring
visible:SELECTORCSS selector matches a visible element (waits up to 5s)
hidden:SELECTORElement is hidden or absent
count:SELECTOR:NExactly N elements match selector
url:PATTERNCurrent URL contains pattern
no-console-errorsNo console.error() calls during load
no-console-warningsNo console.warn() calls during load
console-contains:TEXTAny console message contains text
request:METHOD:PATH:STATUSNetwork request was made (e.g., request:GET:/api/users:200)
no-failed-requestsNo 4xx/5xx responses in network log
status:CODEHTTP response status code matches

Wait-for conditions (verify.py --wait-for, interact.py --wait):

ConditionWaits for
SELECTORCSS selector to be visible (bare selector)
selector:SELECTORCSS selector to be visible (explicit prefix)
text:TEXTVisible text to appear on page
network-idleNetwork to be idle (no pending requests)
url: checks immediately — correct for direct navigation. For client-side redirects, use interact.py with --wait "text:Dashboard" before --assert "url:/dashboard".

Read references/assertion-patterns.md for framework-specific recipes.

interact.py (multi-step flows)

For login flows, form submissions, and multi-page navigation:

# Login flow
python interact.py http://localhost:3000/login \
    --fill "input[name=email]=test@test.com" \
    --fill "input[name=password]=password" \
    --click "button[type=submit]" \
    --wait "text:Dashboard" \
    --assert "url:/dashboard" \
    --assert "text:Welcome"

# Form with screenshot
python interact.py http://localhost:3000/settings \
    --fill "#name=New Name" \
    --select "#role=admin" \
    --click "button:has-text('Save')" \
    --wait "text:Saved" \
    --assert "text:Saved" \
    --screenshot result.png

# Mobile viewport
python interact.py http://localhost:3000 \
    --viewport 375x812 \
    --click "nav button" \
    --wait "text:Menu" \
    --assert "visible:.mobile-menu" \
    --screenshot mobile.png

Ordered actions (executed in the order they appear):

ActionPurpose
--click SELECTORClick an element
--fill "SEL=VALUE"Clear and fill an input field
--select "SEL=VALUE"Select a dropdown option
--type "SEL=VALUE"Type text key-by-key (for autocomplete, etc.)
--wait CONDITIONWait for a condition (see wait-for table above)
--assert ASSERTIONCheck an assertion (see assertions table above)
--screenshot PATHTake screenshot after all actions complete

Actions fail fast on errors (except assertions, which are collected and reported at the end).

snapshot.py (debugging)

# Always include --wait-for to ensure JS has rendered
python snapshot.py http://localhost:3000 --wait-for "h1"
python snapshot.py http://localhost:3000 --wait-for "nav" --selector "main"
python snapshot.py http://localhost:3000 --wait-for "h1" --console

Returns a YAML-like tree:

- heading "Welcome to My App" [level=1]
- navigation "Main":
  - link "Home"
  - link "About"
- main:
  - heading "Dashboard" [level=2]
  - list:
    - listitem "Task 1"
    - listitem "Task 2"

screenshot.py (visual + diagnostic)

# Always include --wait-for to ensure JS has rendered
python screenshot.py http://localhost:3000 --wait-for "h1" --output screenshot.png
python screenshot.py http://localhost:3000 --wait-for "h1" --full-page --output full.png
python screenshot.py http://localhost:3000 --wait-for "h1" --selector "main" --output main.png

Saves the screenshot and prints the accessibility tree + any console errors to stdout.

  • --wait-for waits for the element to appear, then captures the full page (or --selector scope).
  • --selector scopes both the screenshot and accessibility tree to that element.
  • --full-page captures the entire scrollable page (ignored when --selector is used).
  • --console prints ALL console messages (not just errors) in a <console-log> section.

Static sites

For sites with no client-side rendering (plain HTML, Hugo, Jekyll), --wait-for is harmless but unnecessary. You can omit it:

python screenshot.py http://localhost:8080 --output static.png
python snapshot.py http://localhost:8080

Custom Playwright Scripts

For flows that interact.py can't handle, write a Playwright script directly. See references/assertion-patterns.md for custom script patterns (async state, multi-page navigation, canvas/WebGL).

Windows note: Avoid non-ASCII characters (arrows, emojis) in print() statements in custom scripts. Windows consoles may fail with 'charmap' codec can't encode character. Stick to ASCII or set PYTHONIOENCODING=utf-8.

Phase 5: Integrate with Loops (Optional)

For loop agent VERIFY phases, add browser verification to the plan's Verify field:

- [ ] **Add signup page** — ...
  Verify: `python with_server.py --cmd "npm start" --port 3000 -- python verify.py http://localhost:3000/signup --assert "visible:#email" --assert "visible:#password" --assert "text:Sign Up"`

The agent copies the Verify command, runs it, and confirms pass/fail before marking the task done.

Anti-Patterns

AvoidDo Instead
screenshot.py / snapshot.py without --wait-for on SPA appsAlways include --wait-for — it's harmless on static sites and essential for SPAs
Screenshots for every verificationUse verify.py for pass/fail; screenshots only for visual debugging
Custom Playwright scripts for simple login/form flowsUse interact.py — it handles click, fill, wait, assert sequences
Exact text assertions for dynamic contentUse visible:SELECTOR for elements, text: for stable labels
Full test suites in VERIFYVERIFY is for quick smoke checks; full suites belong in CI
Hardcoding portsRead port from project config or use framework defaults
Using --use-chrome in automated loops--use-chrome is for manual debugging; loops should use fresh headless Chromium for reproducibility
--wait-for "network-idle" on pages with WebSocket/SSEUse --wait-for "text:..." or --wait-for "selector:..." — network-idle hangs on persistent connections
Retrying --chrome-port after repeated failuresIf Chrome connection fails 2-3 times, drop --chrome-port and use fresh Chromium with interact.py for auth flows
Ignoring <page-errors> in outputUncaught exceptions are critical — always investigate stack traces before moving on

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.85%
按下载量换算30

Claude

31.98%
按下载量换算26

Cursor

17.85%
按下载量换算15

Gemini CLI

10.19%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills