Skip to content

Commit b90416c

Browse files
authored
Use playwright MCP as the recommended way to test RDoc end to end (ruby#1545)
[Playwright](https://github.com/anthropics/claude-plugins-official/tree/main/external_plugins/playwright) is one of the [official Claude plugins](https://github.com/anthropics/claude-plugins-official) and the underlying MCP is server is maintained by Microsoft. So I think we should migrate to this setup for long-term tool stability and security.
1 parent 19f2725 commit b90416c

2 files changed

Lines changed: 46 additions & 17 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
/tmp
1313
/node_modules
1414
Gemfile.lock
15+
16+
# Playwright MCP uses this folder to store screenshots
17+
.playwright-mcp/

AGENTS.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,12 @@ When making changes to theme CSS or templates (e.g., Darkfish or Aliki themes):
321321

322322
1. **Generate documentation**: Run `bundle exec rake rerdoc` to create baseline
323323
2. **Start HTTP server**: Run `cd _site && python3 -m http.server 8000` (use different port if 8000 is in use)
324-
3. **Investigate with sub-agent**: Use Task tool to launch a general-purpose agent to inspect the documentation with Browser MCP
325-
- The agent will connect browser to `http://localhost:8000`, navigate pages, and take screenshots
326-
- Agent reports findings back (styling issues, layout problems, etc.)
327-
- This saves context in main conversation
324+
3. **Investigate with Playwright**: Ask the AI assistant to take screenshots and inspect the documentation visually
325+
- Example: "Navigate to the docs at localhost:8000 and screenshot the RDoc module page"
326+
- See "Playwright MCP for Testing Generated Documentation" section below for details
328327
4. **Make changes**: Edit files in `lib/rdoc/generator/template/<theme>/` as needed
329328
5. **Regenerate**: Run `bundle exec rake rerdoc` to rebuild documentation with changes
330-
6. **Verify with sub-agent**: Use Task tool again to launch agent that uses Browser MCP to verify fixes
331-
- Agent takes screenshots and compares to original issues
332-
- Agent reports back whether issues are resolved
329+
6. **Verify with Playwright**: Take new screenshots and compare to original issues
333330
7. **Lint changes** (if modified):
334331
- ERB templates: `npx @herb-tools/linter "lib/rdoc/generator/template/**/*.rhtml"`
335332
- CSS files: `npm run lint:css -- --fix`
@@ -349,23 +346,47 @@ When making changes to theme CSS or templates (e.g., Darkfish or Aliki themes):
349346
5. **Verify generated files** with `rake verify_generated`
350347
6. **Don't edit generated files** directly (in `lib/rdoc/markdown/` and `lib/rdoc/rd/`)
351348

352-
## Browser MCP for Testing Generated Documentation
349+
## Playwright MCP for Testing Generated Documentation
353350

354-
Browser MCP allows AI agents to visually inspect and interact with the generated HTML documentation. This is useful for verifying CSS styling, layout issues, and overall appearance.
351+
The Playwright MCP server enables visual inspection and interaction with generated HTML documentation. This is useful for verifying CSS styling, layout issues, and overall appearance.
355352

356-
**Repository:** <https://github.com/BrowserMCP/mcp>
353+
**MCP Server:** `@playwright/mcp` (Microsoft's official browser automation server)
357354

358355
### Setup
359356

360-
If Browser MCP is not already installed, users should:
357+
The Playwright MCP server can be used with any MCP-compatible AI tool (Claude Code, Cursor, GitHub Copilot, OpenAI Agents, etc.).
361358

362-
1. Install the BrowserMCP Chrome extension from the Chrome Web Store
363-
2. Run: `claude mcp add --scope user browsermcp npx @browsermcp/mcp@latest`
364-
3. Connect a browser tab by clicking the BrowserMCP extension icon and selecting "Connect"
359+
**Claude Code:**
360+
361+
```bash
362+
/plugin playwright
363+
```
364+
365+
**Other MCP-compatible tools:**
366+
367+
```bash
368+
npx @playwright/mcp@latest
369+
```
370+
371+
Configure your tool to connect to this MCP server. Playwright launches its own browser instance automatically - no manual browser setup or extensions required.
372+
373+
### Troubleshooting: Chrome Remote Debugging Blocked
374+
375+
If you encounter `DevTools remote debugging is disallowed by the system admin`, Chrome's debugging is blocked by the machine's policy. Use Firefox instead:
376+
377+
```bash
378+
# Install Firefox for Playwright
379+
npx playwright install firefox
380+
381+
# Add Playwright MCP with Firefox to your project (creates/updates .mcp.json)
382+
claude mcp add playwright --scope project -- npx -y @playwright/mcp@latest --browser firefox
383+
```
384+
385+
Restart Claude Code after running these commands.
365386

366387
### Testing Generated Documentation
367388

368-
To test the generated documentation with Browser MCP:
389+
To test the generated documentation:
369390

370391
```bash
371392
# Generate documentation
@@ -377,6 +398,11 @@ cd _site && python3 -m http.server 8000
377398

378399
If port 8000 is already in use, try another port (e.g., `python3 -m http.server 9000`).
379400

380-
Then navigate to the appropriate URL (e.g., `http://localhost:8000`) in your connected browser tab and ask Claude to use browser MCP tools (e.g., "use browser MCP to navigate to <http://localhost:8000> and take a screenshot").
401+
Then ask the AI assistant to inspect the documentation. It will use the appropriate Playwright tools (`browser_navigate`, `browser_snapshot`, `browser_take_screenshot`, etc.) based on your request.
402+
403+
**Example requests:**
381404

382-
**Note:** Browser MCP requires a proper HTTP server (not `file://` URLs) for full functionality. The generated documentation must be served via HTTP/HTTPS.
405+
- "Navigate to `http://localhost:8000` and take a screenshot"
406+
- "Take a screenshot of the RDoc module page"
407+
- "Check if code blocks are rendering properly on the Markup page"
408+
- "Compare the index page before and after my CSS changes"

0 commit comments

Comments
 (0)