browsing-with-playwright by bilalmk/todo_correct
npx skills add https://github.com/bilalmk/todo_correct --skill browsing-with-playwright通过 Playwright MCP 服务器实现浏览器交互自动化。
# 使用辅助脚本(推荐)
bash scripts/start-server.sh
# 或手动启动
npx @playwright/mcp@latest --port 8808 --shared-browser-context &
# 使用辅助脚本(先关闭浏览器)
bash scripts/stop-server.sh
# 或手动停止
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_close -p '{}'
pkill -f "@playwright/mcp"
重要提示: --shared-browser-context 标志是必需的,用于在多个 mcp-client.py 调用之间保持浏览器状态。没有此标志,每次调用都会获得全新的浏览器上下文。
# 访问 URL
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_navigate \
-p '{"url": "https://example.com"}'
# 后退
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_navigate_back -p '{}'
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 无障碍快照(返回用于点击/输入的元素引用)
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_snapshot -p '{}'
# 截图
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_take_screenshot \
-p '{"type": "png", "fullPage": true}'
使用快照输出中的 ref 来定位元素:
# 点击元素
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_click \
-p '{"element": "Submit button", "ref": "e42"}'
# 输入文本
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_type \
-p '{"element": "Search input", "ref": "e15", "text": "hello world", "submit": true}'
# 填写表单(多个字段)
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_fill_form \
-p '{"fields": [{"ref": "e10", "value": "john@example.com"}, {"ref": "e12", "value": "password123"}]}'
# 选择下拉菜单
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_select_option \
-p '{"element": "Country dropdown", "ref": "e20", "values": ["US"]}'
# 等待文本出现
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_wait_for \
-p '{"text": "Success"}'
# 等待时间(毫秒)
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_wait_for \
-p '{"time": 2000}'
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_evaluate \
-p '{"function": "return document.title"}'
对于复杂工作流,使用 browser_run_code 在一次调用中运行多个操作:
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_run_code \
-p '{"code": "async (page) => { await page.goto(\"https://example.com\"); await page.click(\"text=Learn more\"); return await page.title(); }"}'
提示: 对于应该是原子操作(要么全部成功,要么全部失败)的复杂多步骤操作,请使用 browser_run_code。
运行:python3 scripts/verify.py
预期输出:✓ Playwright MCP server running
pgrep -f "@playwright/mcp"bash scripts/start-server.sh完整工具文档请参阅 references/playwright-tools.md。
| 问题 | 解决方案 |
|---|---|
| 找不到元素 | 先运行 browser_snapshot 获取当前引用 |
| 点击失败 | 先尝试 browser_hover,然后再点击 |
| 表单未提交 | 在 browser_type 中使用 "submit": true |
| 页面未加载 | 增加等待时间或使用 browser_wait_for |
| 服务器无响应 | 停止并重启:bash scripts/stop-server.sh && bash scripts/start-server.sh |
每周安装量
1.1K
代码仓库
首次出现
2026年1月24日
安全审计
安装于
opencode1.1K
codex1.1K
gemini-cli1.1K
github-copilot1.1K
kimi-cli1.1K
amp1.1K
Automate browser interactions via Playwright MCP server.
# Using helper script (recommended)
bash scripts/start-server.sh
# Or manually
npx @playwright/mcp@latest --port 8808 --shared-browser-context &
# Using helper script (closes browser first)
bash scripts/stop-server.sh
# Or manually
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_close -p '{}'
pkill -f "@playwright/mcp"
Important: The --shared-browser-context flag is required to maintain browser state across multiple mcp-client.py calls. Without it, each call gets a fresh browser context.
# Go to URL
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_navigate \
-p '{"url": "https://example.com"}'
# Go back
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_navigate_back -p '{}'
# Accessibility snapshot (returns element refs for clicking/typing)
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_snapshot -p '{}'
# Screenshot
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_take_screenshot \
-p '{"type": "png", "fullPage": true}'
Use ref from snapshot output to target elements:
# Click element
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_click \
-p '{"element": "Submit button", "ref": "e42"}'
# Type text
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_type \
-p '{"element": "Search input", "ref": "e15", "text": "hello world", "submit": true}'
# Fill form (multiple fields)
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_fill_form \
-p '{"fields": [{"ref": "e10", "value": "john@example.com"}, {"ref": "e12", "value": "password123"}]}'
# Select dropdown
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_select_option \
-p '{"element": "Country dropdown", "ref": "e20", "values": ["US"]}'
# Wait for text to appear
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_wait_for \
-p '{"text": "Success"}'
# Wait for time (ms)
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_wait_for \
-p '{"time": 2000}'
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_evaluate \
-p '{"function": "return document.title"}'
For complex workflows, use browser_run_code to run multiple actions in one call:
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_run_code \
-p '{"code": "async (page) => { await page.goto(\"https://example.com\"); await page.click(\"text=Learn more\"); return await page.title(); }"}'
Tip: Use browser_run_code for complex multi-step operations that should be atomic (all-or-nothing).
Run: python3 scripts/verify.py
Expected: ✓ Playwright MCP server running
pgrep -f "@playwright/mcp"bash scripts/start-server.shSee references/playwright-tools.md for complete tool documentation.
| Issue | Solution |
|---|---|
| Element not found | Run browser_snapshot first to get current refs |
| Click fails | Try browser_hover first, then click |
| Form not submitting | Use "submit": true with browser_type |
| Page not loading | Increase wait time or use browser_wait_for |
| Server not responding | Stop and restart: bash scripts/stop-server.sh && bash scripts/start-server.sh |
Weekly Installs
1.1K
Repository
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykFail
Installed on
opencode1.1K
codex1.1K
gemini-cli1.1K
github-copilot1.1K
kimi-cli1.1K
amp1.1K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
AI智能体长期记忆系统 - 精英级架构,融合6种方法,永不丢失上下文
1,200 周安装
AI新闻播客制作技能:实时新闻转对话式播客脚本与音频生成
1,200 周安装
Word文档处理器:DOCX创建、编辑、分析与修订痕迹处理全指南 | 自动化办公解决方案
1,200 周安装
React Router 框架模式指南:全栈开发、文件路由、数据加载与渲染策略
1,200 周安装
Nano Banana AI 图像生成工具:使用 Gemini 3 Pro 生成与编辑高分辨率图像
1,200 周安装
SVG Logo Designer - AI 驱动的专业矢量标识设计工具,生成可缩放品牌标识
1,200 周安装