当前位置: 首页 > Skill >

Playwright 1.0.3

Playwright 1.0.3

Playwright 1.0.3

通过 Playwright MCP 实现浏览器自动化。导航网站、点击元素、填写表单、截取屏幕截图、提取数据以及调试真实浏览器工作流程。使用 w...

1.0.0 2026.11.11 669
获取Skill文件查看使用说明
作 者:苏言 许可证: 更新时间:2026.11.11
本文目录展开

When to Use

Use this skill for real browser tasks: JS-rendered pages, multi-step forms, screenshots or PDFs, UI debugging, Playwright test authoring, MCP-driven browser control, and structured extraction from rendered pages.

Prefer it when static fetch is insufficient or when the task depends on browser events, visible DOM state, authentication context, uploads or downloads, or user-facing rendering.

If the user mainly wants the agent to drive a browser with simple actions like navigate, click, fill, screenshot, download, or extract, treat MCP as a first-class path.

Use direct Playwright for scripts and tests. Use MCP when browser tools are already in the loop, the user explicitly wants MCP, or the fastest path is browser actions rather than writing new automation code.

Primary fit is repo-owned browser work: tests, debugging, repros, screenshots, and deterministic automation. Treat rendered-page extraction as a secondary use case, not the default identity.

Architecture

This skill is instruction-only. It does not create local memory, setup folders, or persistent profiles by default.

Load only the smallest reference file needed for the task. Keep auth state temporary unless the repository already standardizes it and the user explicitly wants browser-session reuse.

Quick Start

MCP browser path

npx @playwright/mcp --headless

Use this path when the agent already has browser tools available or the user wants browser automation without writing new Playwright code.

Common MCP actions

Typical Playwright MCP tool actions include:

  • browser_navigate for opening a page
  • browser_click and browser_press for interaction
  • browser_type and browser_select_option for forms
  • browser_snapshot and browser_evaluate for inspection and extraction
  • browser_choose_file for uploads
  • screenshot, PDF, trace, and download capture through the active browser workflow

Common browser outcomes

Goal Typical MCP-style action
Open and inspect a site navigate, wait, inspect, screenshot
Complete a form navigate, click, fill, select, submit
Capture evidence screenshot, PDF, download, trace
Pull structured page data navigate, wait for rendered state, extract
Reproduce a UI bug headed run, trace, console or network inspection

Existing test suite

npx playwright test
npx playwright test --headed
npx playwright test --trace on

Bootstrap selectors and flows

npx playwright codegen https://example.com

Direct script path

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({ path: 'page.png', fullPage: true });
  await browser.close();
})();

Quick Reference

Topic File
Selector strategy and frame handling selectors.md
Failure analysis, traces, logs, and headed runs debugging.md
Test architecture, mocks, auth, and assertions testing.md
CI defaults, retries, workers, and failure artifacts ci-cd.md
Rendered-page extraction, pagination, and respectful throttling scraping.md

Approach Selection

Situation Best path Why
Static HTML or a simple HTTP response is enough Use a cheaper fetch path first Faster, cheaper, less brittle
You need a reliable first draft of selectors or flows Start with codegen or a headed exploratory run Faster than guessing selectors from source or stale DOM
Local app, staging app, or repo-owned E2E suite Use @playwright/test Best fit for repeatable tests and assertions
One-off browser automation, screenshots, downloads, or rendered extraction Use direct Playwright API Simple, explicit, and easy to debug in code
Agent/browser-tool workflow already depends on browser_* tools or the user wants no-code browser control Use Playwright MCP Fastest path for navigate-click-fill-screenshot workflows
CI failures, flake, or environment drift Start with debugging.md and ci-cd.md Traces and artifacts matter more than new code

Core Rules

1. Test user-visible behavior and the real browser boundary

  • Do not spend Playwright on implementation details that unit or API tests can cover more cheaply.
  • Use Playwright when success depends on rendered UI, actionability, auth, uploads or downloads, navigation, or browser-only behavior.

2. Make runs isolated before making them clever

  • Keep tests and scripts independent so retries, parallelism, and reruns do not inherit hidden state.
  • Extend the repository's existing Playwright harness, config, and fixtures before inventing a parallel testing shape from scratch.
  • Do not share mutable accounts, browser state, or server-side data across parallel runs unless the suite was explicitly designed for it.

3. Reconnaissance before action

  • Open, wait, and inspect the rendered state before locking selectors or assertions.
  • Use codegen, headed mode, or traces to discover stable locators instead of guessing from source or stale DOM.
  • For flaky or CI-only failures, capture a trace before rewriting selectors or waits.

4. Prefer resilient locators and web-first assertions

  • Use role, label, text, alt text, title, or test ID before CSS or XPath.
  • Assert the user-visible outcome with Playwright assertions instead of checking only that a click or fill command executed.
  • If a locator is ambiguous, disambiguate it. Do not silence strictness with first(), last(), or nth() unless position is the actual behavior under test.

5. Wait on actionability and app state, not arbitrary time

  • Let Playwright's actionability checks work for you before reaching for sleeps or forced actions.
  • Prefer expect, URL waits, response waits, and explicit app-ready signals over generic timing guesses.

6. Control what you do not own

  • Mock or isolate third-party services, flaky upstream APIs, analytics noise, and cross-origin dependencies whenever the goal is to verify your app.
  • For rendered extraction, prefer documented APIs or plain HTTP paths before driving a full browser.
  • Do not make live third-party widgets or upstream integrations the reason your suite flakes unless that exact integration is what the user asked to validate.

7. Keep auth, production access, and persistence explicit

  • Do not persist saved browser state by default.
  • Reuse auth state only when the repository already standardizes it or the user explicitly asks for session reuse.
  • For destructive, financial, medical, production, or otherwise high-stakes flows, prefer staging or local environments and require explicit user confirmation before continuing.

Playwright Traps

  • Guessing selectors from source or using first(), last(), or nth() to silence ambiguity -> the automation works once and then flakes.
  • Starting a new Playwright structure when the repo already has config, fixtures, auth setup, or conventions -> the new flow fights the existing harness and wastes time.
  • Testing internal implementation details instead of visible outcomes -> the suite passes while the user path is still broken.
  • Sharing one authenticated state across parallel tests that mutate server-side data -> failures become order-dependent and hard to trust.
  • Reaching for force: true before understanding overlays, disabled state, or actionability -> the test hides a real bug.
  • Waiting on networkidle for chatty SPAs -> analytics, polling, or sockets keep the page "busy" even when the UI is ready.
  • Driving a full browser when HTTP or an API would answer the question -> more cost, more flake, less signal.
  • Treating third-party widgets and live upstream services as if they were stable parts of your own product -> failures stop being actionable.

External Endpoints

Endpoint Data Sent Purpose
User-requested web origins Browser requests, form input, cookies, uploads, and page interactions required by the task Automation, testing, screenshots, PDFs, and rendered extraction
https://registry.npmjs.org Package metadata and tarballs during optional installation Install Playwright or Playwright MCP

No other data is sent externally.

Security & Privacy

Data that leaves your machine:

  • Requests sent to the websites the user asked to automate.
  • Optional package-install traffic to npm when installing Playwright tooling.

Data that stays local:

  • Source code, traces, screenshots, videos, PDFs, and temporary browser state kept in the workspace or system temp directory.

This skill does NOT:

  • Create hidden memory files or local folder systems.
  • Recommend browser-fingerprint hacks, challenge-solving services, or rotating exits.
  • Persist sessions or credentials by default.
  • Make undeclared network requests beyond the target sites involved in the task and optional tool installation.
  • Treat high-stakes production flows as safe to automate without explicit user direction.

Trust

By using this skill, browser requests go to the websites you automate and optional package downloads go through npm. Only install if you trust those services and the sites involved in your workflow.

Related Skills

Install with clawhub install <slug> if user confirms:

  • web - HTTP-first investigation before escalating to a real browser.
  • scrape - Broader extraction workflows when browser automation is not the main challenge.
  • screenshots - Capture and polish visual artifacts after browser work.
  • multi-engine-web-search - Find and shortlist target pages before automating them.

Feedback

  • If useful: clawhub star playwright
  • Stay updated: clawhub sync

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,037
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,020
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,016
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,015
Skill 文件
  • SKILL.md
    • When to Use
    • Architecture
    • Quick Start
      • MCP browser path
      • Common MCP actions
      • Common browser outcomes
      • Existing test suite
      • Bootstrap selectors and flows
      • Direct script path
    • Quick Reference
    • Approach Selection
    • Core Rules
      • 1. Test user-visible behavior and the real browser boundary
      • 2. Make runs isolated before making them clever
      • 3. Reconnaissance before action
      • 4. Prefer resilient locators and web-first assertions
      • 5. Wait on actionability and app state, not arbitrary time
      • 6. Control what you do not own
      • 7. Keep auth, production access, and persistence explicit
    • Playwright Traps
    • External Endpoints
    • Security & Privacy
    • Trust
    • Related Skills
    • Feedback
  • 项目或源文件

相关 Skill

更多
Playwright.Tmp Playwright.Tmp 通过 Playwright MCP 实现浏览器自动化。可导航网站、点击元素、填写表单、截图、提取数据及调试真实浏览器工作流。使用 w...
FastPlayWright Skill FastPlayWright Skill 高性能浏览器自动化工具,基于Fast Playwright MCP。支持token优化的批量执行、智能元素选择(带回退机制)、差异检测...
Playwright by Xiaomolong Playwright by Xiaomolong 通过 Playwright MCP 实现浏览器自动化。导航网站、点击元素、填写表单、截取屏幕截图、提取数据以及调试真实浏览器工作流程。使用 w...
Playwright MCP Playwright MCP { "answer": "通过 Playwright MCP 服务器实现浏览器自动化。可导航网站、点击元素、填写表单、提取数据、截图,并执行完整的浏览器自动化工作流。" }
Playwright (Automation + MCP + Scraper) Playwright (Automation + MCP + Scraper) 通过 Playwright MCP 实现浏览器自动化。可导航网站、点击元素、填写表单、截图、提取数据及调试真实浏览器工作流。使用 w...