The returned context is the only context; get a page with const page = await context.newPage()
Perform login or setup actions — cookies, local storage, and IndexedDB are automatically written to profileDir on close
On subsequent runs, pass the same profileDir; Playwright restores the saved session data
Call await context.close() to flush all state to disk before the process exits
Known gotchas
Only one Playwright process may use a given userDataDir at a time; launching a second instance against the same directory will fail or corrupt the profile
Automating the user's real default Chrome profile is blocked by Chrome policy; always use a dedicated directory created solely for automation
Persistent contexts do not support the page.storageState() round-trip approach; they write directly to the Chrome profile format, which can break between major Chrome version upgrades
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp