12 traps when Claude Code drives your real Chrome through Playwright MCP (and the fixes)
Описание и применение
Автоматизация реального профиля Chrome через Playwright MCP стала стабильной благодаря выделенному профилю, проверке видимости окна, использованию insertText для не‑ASCII, проверке состояния редакторов и скрытому вводу файлов.
Задача
Automating a real Chrome profile via Playwright MCP often fails due to visibility, hidden windows, non‑ASCII input, editor state drift, and file handling issues.
Результат
Daily automation of real Chrome profiles became stable, with reduced timeouts, correct character handling, and reliable form submissions.
Рабочий процесс
- 1. Create a dedicated user‑data‑dir and log in manually. 2. Launch Chrome with --remote‑debugging‑port and the dedicated dir. 3. Connect Playwright MCP via CDP endpoint. 4. Before each click, check document.visibilityState; if hidden, bring window to front using SetWindowPos. 5. For new tabs, call page.bringToFront(). 6. Use page.keyboard.insertText() for non‑ASCII input. 7. In rich‑text editors, use document.execCommand('selectAll') before typing and verify with a visible counter. 8. For ProseMirror editors, dispatch a paste event with text/html data and verify heading/ list structure. 9. To upload a local file, create a hidden input[type=file], setInputFiles(), and read the file on the page. 10. After each operation, confirm the expected state (e.g., form values, post content).
Доказательства
Recent Chrome (136 and later) refuses --remote-debugging-port on the default profile.
TimeoutError: locator.click: Timeout 30000ms exceeded. - waiting for element to be visible, enabled and stable
- Дата записи: 2026-09-21T21:00:30.231Z