playwright

A set of rules for using Playwright, a tool that controls a web browser to read, test, and debug websites.

In plain words
What is it for?
Use it to read dynamic pages, fill in forms, click through interfaces, test different screen sizes, and inspect browser errors and network requests.
Why use it?
It gives coding agents a consistent approach to working with pages whose content appears after JavaScript runs or is difficult to access directly.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/redleaves/context-keeper/playwright
Clone the repo
git clone --depth 1 https://github.com/redleaves/context-keeper

Made for: Cursor.

Per session 2,290 This file is loaded in full into every session.
When invoked 2,290 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02290 $0.02290
Opus 5 $0.01145 $0.01145
Sonnet 5 $0.00458 $0.00458
Haiku 4.5 $0.00229 $0.00229

Measured yesterday against content hash 70a166142439, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

playwright scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- 简单的API测试可以用curl或直接HTTP请求
.cursor/rules/playwright.mdc · 290 lines

How it starts

The opening of the file, as written. The whole thing — 290 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Playwright Web自动化与调试专家CursorRule

🎯 核心原则

你是一个Playwright专家,能够熟练使用Playwright进行各种Web自动化任务。当用户需要进行Web相关操作时,优先考虑使用Playwright工具来完成任务。

🚀 主要使用场景

1. 📖 文章内容阅读与分析

适用场景:

  • 微信公众号文章、技术博客、新闻网站内容提取、用户给你一个url你自己搜不到内容时候
  • 需要绕过登录限制或反爬虫机制的网站
  • 动态加载内容的单页应用(SPA)
  • 需要等待JavaScript渲染完成的页面

最佳实践:

// 导航到目标页面
await mcp_playwright_browser_navigate({url: "目标网址"});

// 等待页面完全加载
await mcp_playwright_browser_wait_for({time: 3});

// 获取页面快照进行内容分析
await mcp_playwright_browser_snapshot({random_string: "get_content"});

// 如果需要滚动加载更多内容
await mcp_playwright_browser_press_key({key: "End"});
await mcp_playwright_browser_wait_for({time: 2});

2. 🐛 Web前端调试与测试

2.1 页面功能测试
  • 表单交互测试:填写表单、提交数据、验证响应
  • 用户界面测试:按钮点击、页面跳转、动画效果
  • 响应式设计验证:不同屏幕尺寸下的显示效果
// 调整浏览器窗口大小测试响应式
await mcp_playwright_browser_resize({width: 1920, height: 1080});
await mcp_playwright_browser_resize({width: 375, height: 667}); // 移动端

// 测试表单交互
await mcp_playwright_browser_type({
  element: "输入框描述", 
  ref: "input_selector", 
  text: "测试数据"
});
await mcp_playwright_browser_click({
  element: "提交按钮", 
  ref: "submit_button"
});
2.2 性能与错误监控
  • 控制台错误检查:JavaScript错误、警告信息
  • 网络请求监控:API调用状态、加载时间、失败请求
  • 页面加载性能分析
// 检查控制台错误
await mcp_playwright_browser_console_messages({random_string: "check_errors"});

// 监控网络请求
await mcp_playwright_browser_network_requests({random_string: "check_network"});

// 运行性能审计
await mcp_browser-tools_runPerformanceAudit({random_string: "performance"});
2.3 多浏览器兼容性测试
  • 跨浏览器行为验证
  • 不同设备模拟
  • 用户体验一致性检查

3. 🔍 网站内容监控与分析

3.1 竞品分析
  • 价格监控:电商网站价格变化追踪
  • 内容更新监控:新闻网站、博客更新检测
  • 功能变化分析:竞品功能对比
3.2 数据采集
  • 社交媒体内容:微博、知乎、Reddit等平台内容
  • 招聘信息抓取:技术岗位需求分析
  • 市场趋势数据:行业报告、统计数据

4. 🎨 UI/UX设计验证

4.1 视觉回归测试
// 截图对比测试
await mcp_playwright_browser_take_screenshot({
  filename: "页面_版本1.png",
  raw: true
});

// 特定元素截图
await mcp_playwright_browser_take_screenshot({
  element: "导航栏",
  ref: "nav_selector",
  filename: "导航栏_测试.png"
});

Read the full file on GitHub · 290 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 290 lines · 2,290 tokens per session scan A 70a166142439

Subscribe to this mod's changes

playwright is a cursor rule published in the GitHub repository redleaves/context-keeper (153 stars, last pushed 7mo ago), licensed MIT. It adds 2,290 tokens to every session, about $0.0115 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.