@@ -82,6 +82,12 @@ Type: [object][6]
82
82
* ` recordHar ` ** [ object] [ 6 ] ?** record HAR and will be saved to ` output/har ` . See more of [ HAR options] [ 3 ] .
83
83
* ` testIdAttribute ` ** [ string] [ 9 ] ?** locate elements based on the testIdAttribute. See more of [ locate by test id] [ 49 ] .
84
84
* ` 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.
85
91
86
92
87
93
@@ -1333,6 +1339,28 @@ let pageSource = await I.grabSource();
1333
1339
1334
1340
Returns ** [ Promise] [ 22 ] <[ string] [ 9 ] >** source code
1335
1341
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
+
1336
1364
### grabTextFrom
1337
1365
1338
1366
Retrieves a text from an element located by CSS or XPath and returns it to test.
0 commit comments