browsing-with-playwright
bilalmk/todo_correct
Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction. NOT when only fetching static content (use curl/wget instead).
...Expand allAbout browsing-with-playwright
The browsing-with-playwright skill enables browser automation through the Playwright MCP server, allowing you to programmatically control web browsers for tasks that require actual browser interaction. This skill solves the problem of needing to interact with dynamic web content, fill out forms, click buttons, extract data from JavaScript-heavy sites, and perform UI testing—all scenarios where simple HTTP requests fall short because they cannot execute JavaScript or interact with the DOM.
The skill provides comprehensive browser control capabilities including navigation, element interaction (clicking, typing, form filling, dropdown selection), page state inspection through accessibility snapshots and screenshots, waiting for dynamic content, and JavaScript execution. It maintains browser state across multiple operations using a shared browser context, making it suitable for multi-step workflows like logging into accounts, navigating through multi-page forms, or scraping data from sites that require interaction. The MCP server can be controlled via command-line calls to interact with specific elements identified through accessibility snapshots.
This skill is ideal for developers and automation engineers who need to automate web interactions, QA professionals performing UI testing, data engineers scraping dynamic websites, and anyone working with web applications that require actual browser rendering and interaction. Use this when tasks involve form submissions, clicking through interfaces, waiting for dynamic content to load, or any scenario where the browser's JavaScript engine and rendering capabilities are required. For simple static content fetching, traditional tools like curl or wget remain more efficient.
FAQ
When should I use this skill instead of simple HTTP requests?
Use this skill when you need to interact with dynamic web content that requires JavaScript execution, fill forms, click buttons, wait for content to load, or perform any browser-based interaction. Use curl or wget for fetching static content where no browser interaction is needed.
Why is the --shared-browser-context flag important?
The --shared-browser-context flag maintains browser state (cookies, localStorage, session data) across multiple mcp-client.py calls. Without it, each call starts with a fresh browser context, losing login sessions and other stateful data between operations.
How do I interact with specific elements on a page?
First, use browser_snapshot to get an accessibility tree of the page, which returns element references (like 'e42', 'e15'). Then use these refs in interaction commands like browser_click, browser_type, or browser_fill_form to target specific elements.
When should I use browser_run_code instead of individual commands?
Use browser_run_code for complex multi-step workflows that should execute atomically (all-or-nothing). This is more efficient than multiple separate calls and ensures the entire operation succeeds or fails as a unit.
When should I stop the Playwright server?
Stop the server when your browser automation task is complete to free up resources. Keep it running if you're performing multiple browser tasks in sequence. If the browser becomes unresponsive, stop and restart the server.
All Files
6 filesscripts/mcp-client.py16.9 KBViewSKILL.md4.9 KBViewscripts/stop-server.sh0.9 KBViewreferences/playwright-tools.md20.7 KBViewscripts/verify.py0.5 KBViewscripts/start-server.sh0.7 KBViewAutomate browser interactions via Playwright MCP server.
Server Lifecycle
Start Server
# Using helper script (recommended)bash scripts/start-server.sh# Or manuallynpx @playwright/mcp@latest --port 8808 --shared-browser-context &
Stop Server
# Using helper script (closes browser first)bash scripts/stop-server.sh# Or manuallypython3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_close -p '{}'pkill -f "@playwright/mcp"
When to Stop
- End of task: Stop when browser work is complete
- Long sessions: Keep running if doing multiple browser tasks
- Errors: Stop and restart if browser becomes unresponsive
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.
Quick Reference
Navigation
# Go to URLpython3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_navigate \ -p '{"url": "https://example.com"}'# Go backpython3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_navigate_back -p '{}'
Get Page State
# Accessibility snapshot (returns element refs for clicking/typing)python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_snapshot -p '{}'# Screenshotpython3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_take_screenshot \ -p '{"type": "png", "fullPage": true}'
Interact with Elements
Use ref from snapshot output to target elements:
# Click elementpython3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_click \ -p '{"element": "Submit button", "ref": "e42"}'# Type textpython3 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": "[email protected]"}, {"ref": "e12", "value": "password123"}]}'# Select dropdownpython3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_select_option \ -p '{"element": "Country dropdown", "ref": "e20", "values": ["US"]}'
Wait for Conditions
# Wait for text to appearpython3 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}'
Execute JavaScript
python3 scripts/mcp-client.py call -u http://localhost:8808 -t browser_evaluate \ -p '{"function": "return document.title"}'Multi-Step Playwright Code
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).
Workflow: Form Submission
- Navigate to page
- Get snapshot to find element refs
- Fill form fields using refs
- Click submit
- Wait for confirmation
- Screenshot result
Workflow: Data Extraction
- Navigate to page
- Get snapshot (contains text content)
- Use browser_evaluate for complex extraction
- Process results
Verification
Run: python3 scripts/verify.py
Expected: ✓ Playwright MCP server running
If Verification Fails
- Run diagnostic:
pgrep -f "@playwright/mcp" - Check: Server process running on port 8808
- Try:
bash scripts/start-server.sh - Stop and report if still failing - do not proceed with downstream steps
Tool Reference
See references/playwright-tools.md for complete tool documentation.
Troubleshooting
| 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 |
Install browsing-with-playwright
Download and extract the skill files to your .claude/skills/ directory.
Download ZIPClone the repository and copy the skill files to your project.
git clone https://github.com/bilalmk/todo_correct/blob/main/.claude/skills/mjs/browsing-with-playwright/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
Copy





Home
