Save a login session
save-loginLog in once and save the session as a storageState file for tests and page tools; valid sessions are reused, expired ones trigger a fresh login with secrets kept out of chat.
Instructions
Log in once and save the session as a storageState file (default playwright/.auth/.json) for tests and the page tools. If a saved session still passes verify it is reused; expired ones log in again. Secrets stay out of chat: fill values use {{env:E2E_PASSWORD}} and {{totp}} (authenticator code from totpSecretEnv).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Login page URL (http/https) | |
| name | No | Session name, e.g. 'admin' (default 'user'); saved to playwright/.auth/<name>.json | |
| path | No | Where to save the storageState JSON inside the project (overrides name) | |
| reuse | No | Keep a saved session that still passes verify instead of logging in again (default true) | |
| verify | No | How to tell the session works; also used to decide whether a saved session is still valid | |
| actions | No | Login steps. In fill values write {{env:E2E_PASSWORD}} for a secret from the environment and {{totp}} for an authenticator code, never the secret itself. End with a 'wait' on something only signed-in users see | |
| headers | No | Extra HTTP headers | |
| viewport | No | ||
| timeoutMs | No | Overall limit in ms (default 60000) | |
| projectRoot | No | Project directory (default: server root) | |
| totpSecretEnv | No | Environment variable holding the authenticator secret (base32 or otpauth:// URI), for {{totp}} | |
| actionTimeoutMs | No | How long each step waits for its element (default 10000) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | false when the call failed (see error) or the tests it ran failed | |
| url | No | ||
| path | No | save-login: the storageState file, relative to the project | |
| error | No | ||
| valid | No | validate-selector: the selector parsed and ran | |
| status | No | ||
| expiresAt | No | save-login: when the first session cookie expires (ISO) |