Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Cloudflare Blocked My Playwright Login. Attaching to a Chrome I Started Yourself Walked Straight Through

说明与用途

手动启动 Chrome 并通过 CDP 连接,绕过 Cloudflare Turnstile 检测,从而实现 Playwright 自动化。

问题

Playwright automation was blocked by Cloudflare Turnstile when launching Chrome, causing login failures.

结果

By launching Chrome manually and attaching via CDP, the bot check was bypassed, allowing Playwright to log in and read deploy logs efficiently.

工作流

  • 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.

证据

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.

来源

  • 记录日期: 2026-09-15T09:00:32.404Z