Reuse a manual browser login in Playwright (storageState)
Short answerLog in manually in a QA SessionLab session (MFA, SSO and captchas included), then use “⤓ Playwright storageState” to export its cookies and localStorage as a storageState JSON file that Playwright can load with browser.newContext({ storageState }).
Step by step
- Create a session and log in by handOpen your app in a new session tab and complete the login, including any MFA or SSO step.
- Export storageStateIn the session’s details choose “⤓ Playwright storageState” (or “Copy JSON”).
- Load it in PlaywrightUse the file with browser.newContext({ storageState: 'admin.storageState.json' }) or test.use({ storageState }).
- Go the other wayUse “⤒ Import” in the Sessions panel to turn any storageState JSON into a live session you can inspect by hand.
Why this works
- Scripting MFA or third-party SSO in tests is fragile; a captured state is reliable.
- Exported state contains only that role’s cookies and storage, not your personal browser profile.
Questions
Does it include HttpOnly cookies?
Yes. QA SessionLab captures Set-Cookie headers itself, so HttpOnly session cookies are included in the export.
Is it safe to commit the file?
No — it contains live login cookies. Keep it out of version control or use short-lived test accounts.