@@ -82,6 +82,12 @@ Type: [object][6]
8282* ` recordHar ` ** [ object] [ 6 ] ?** record HAR and will be saved to ` output/har ` . See more of [ HAR options] [ 3 ] .
8383* ` testIdAttribute ` ** [ string] [ 9 ] ?** locate elements based on the testIdAttribute. See more of [ locate by test id] [ 49 ] .
8484* ` customLocatorStrategies ` ** [ object] [ 6 ] ?** custom locator strategies. An object with keys as strategy names and values as JavaScript functions. Example: ` { byRole: (selector, root) => { return root.querySelector( ` [ role="${selector}"] ` ) } } `
85+ * ` storageState ` ** ([ string] [ 9 ] | [ object] [ 6 ] )?** Playwright storage state (path to JSON file or object)
86+ passed directly to ` browser.newContext ` .
87+ If a Scenario is declared with a ` cookies ` option (e.g. ` Scenario('name', { cookies: [...] }, fn) ` ),
88+ those cookies are used instead and the configured ` storageState ` is ignored (no merge).
89+ May include session cookies, auth tokens, localStorage and (if captured with
90+ ` grabStorageState({ indexedDB: true }) ` ) IndexedDB data; treat as sensitive and do not commit.
8591
8692
8793
@@ -1333,6 +1339,28 @@ let pageSource = await I.grabSource();
13331339
13341340Returns ** [ Promise] [ 22 ] <[ string] [ 9 ] >** source code
13351341
1342+ ### grabStorageState
1343+
1344+ Grab the current storage state (cookies, localStorage, etc.) via Playwright's ` browserContext.storageState() ` .
1345+ Returns the raw object that Playwright provides.
1346+
1347+ Security: The returned object can contain authentication tokens, session cookies
1348+ and (when ` indexedDB: true ` is used) data that may include user PII. Treat it as a secret.
1349+ Avoid committing it to source control and prefer storing it in a protected secrets store / CI artifact vault.
1350+
1351+ #### Parameters
1352+
1353+ * ` options ` ** [ object] [ 6 ] ?**
1354+
1355+ * ` options.indexedDB ` ** [ boolean] [ 26 ] ?** set to true to include IndexedDB in snapshot (Playwright >=1.51)```js
1356+ // basic usage
1357+ const state = await I.grabStorageState();
1358+ require('fs').writeFileSync('authState.json', JSON.stringify(state));
1359+
1360+ // include IndexedDB when using Firebase Auth, etc.
1361+ const stateWithIDB = await I.grabStorageState({ indexedDB: true });
1362+ ```
1363+
13361364### grabTextFrom
13371365
13381366Retrieves a text from an element located by CSS or XPath and returns it to test.
0 commit comments