Cloudflare Blocked My Playwright Login. Attaching to a Chrome I Started Yourself Walked Straight Through
Description and use
Launching Chrome manually with a remote debugging port and attaching via CDP bypasses Cloudflare Turnstile, enabling Playwright automation.
Problem
Playwright automation was blocked by Cloudflare Turnstile when launching Chrome, causing login failures.
Outcome
By launching Chrome manually and attaching via CDP, the bot check was bypassed, allowing Playwright to log in and read deploy logs efficiently.
Workflow
- 1. Launch Chrome manually with remote debugging port and a dedicated user-data-dir: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222 --user-data-dir="$HOME/.config/chrome-cdp"
- 2. Log in to the dashboard once in this window.
- 3. In Playwright, open a page target before connecting: use a script to ensure at least one page is open via the CDP endpoint.
- 4. Connect to the running Chrome with playwright.chromium.connect_over_cdp("http://127.0.0.1:9222").
- 5. Create a new context and page, then navigate to the desired URL.
- 6. Handle teardown carefully: skip closing the context when attached to avoid logging out.
- 7. Avoid copying authenticated profile directories; keep the session in its original location.
Evidence
Playwright attaches a set of automation switches when it starts a browser process. Selecting channel="chrome" changes which executable those switches are applied to; it does not remove them.
If the running Chrome has no page target open, connect_over_cdp throws while connecting.
- Record date: 2026-09-15T09:00:32.404Z