First open Chrome like this:
C:\Program Files\Google\Chrome\Application\chrome.exe
--remote-debugging-port=9222
--user-data-dir="C:\Users\User\AppData\Local\Google\Chrome\User Data\Profile 2"
--save-storage
Find the profile dir with chrome://version/
Then manually log in to the website you want to automate.
Now run: npx playwright codegen --target=javascript -o script.js https://example.com
...and it will record your actions.
After that, Playwright can connect to chrome and repeat the actions.
More notes
- If you need exact mouse trajectories or raw timestamps: Use rrweb to record events in-page and replay to produce precise input traces. Or capture DevTools Protocol Input events (use a small recorder that listens to
Input.dispatchMouseEventandInput.dispatchKeyEvent) and convert to Playwright calls (page.mouse.move+page.mouse.down/up+page.keyboard.type).