ZP Posted on May 30 Debugging Playwright CDP Sessions That Lose Cookies and Proxy Context # playwright # automation # ai # webdev I started treating this as a separate bug class after seeing the same failure pattern repeat: A human opens a browser profile and is logged in. A Playwright script attaches through CDP . The page opens. Then the workflow behaves as if the session is empty, the account is logged out, or the request is coming from the wrong proxy . The tempting fix is to add waits or rewrite selectors. That is usually the wrong first move. When a CDP-attached session loses auth state or proxy context , the first question is not: Which selector changed? It is: Did my script attach to the same browser identity that I verified manually? This note is a practical debugging checklist for that problem. Problem: Playwright attaches to an existing Chromium browser, but cookies , session state , or proxy context do not match what I expected. Scope: Chromium , connectOverCDP , browser profiles , persistent sessions , headless checks , and AI agent debugging . Not covered: bypassing platform protections, CAPTCHA handling, or moving auth data between unrelated accounts. The failure pattern The run usually looks healthy from the outside. The browser starts. The CDP endpoint responds. Playwright connects. The page loads. The script can click and read the DOM. But the environment is wrong. You may see one or more of these symptoms: Cookies are empty or fewer than expected. The app redirects to login after refresh. localStorage exists, but the app still treats the user as logged out. The account works manually but fails when attached through CDP . The public IP does not match the expected proxy route . The task works in visible mode but fails in headless mode . An AI browser agent retries the task and marks it successful from a different context. That last case is especially easy to miss. A normal script often stops when the environment changes. An AI agent may continue, ad
Back to Home

Debugging Playwright CDP Sessions That Lose Cookies and Proxy Context
B
Blizine Admin
·2 min read·0 views
📰Dev.to — dev.to
B
Blizine Admin
View Profile Staff Writer