Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/docs/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ await BrowserContext.SetOfflineAsync(offline);

<font size="2" style={{position: "relative", top: "-20px"}}>Added before v1.9</font><x-search>browserContext.StorageStateAsync</x-search>

Returns storage state for this browser context, contains current cookies and local storage snapshot.
Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot.

**Usage**

Expand Down
6 changes: 3 additions & 3 deletions dotnet/docs/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ Redoing login for every test can slow down test execution. To mitigate that, reu

Playwright provides a way to reuse the signed-in state in the tests. That way you can log in only once and then skip the log in step for all of the tests.

Web apps use cookie-based or token-based authentication, where authenticated state is stored as [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) or in [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage). Playwright provides [BrowserContext.StorageStateAsync()](/api/class-browsercontext.mdx#browser-context-storage-state) method that can be used to retrieve storage state from authenticated contexts and then create new contexts with prepopulated state.
Web apps use cookie-based or token-based authentication, where authenticated state is stored as [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), in [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) or in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API). Playwright provides [BrowserContext.StorageStateAsync()](/api/class-browsercontext.mdx#browser-context-storage-state) method that can be used to retrieve storage state from authenticated contexts and then create new contexts with prepopulated state.

Cookies and local storage state can be used across different browsers. They depend on your application's authentication model: some apps might require both cookies and local storage.
Cookies, local storage and IndexedDB state can be used across different browsers. They depend on your application's authentication model which may require some combination of cookies, local storage or IndexedDB.

The following code snippet retrieves state from an authenticated context and creates a new context with that state.

Expand All @@ -99,7 +99,7 @@ var context = await browser.NewContextAsync(new()

### Session storage

Reusing authenticated state covers [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) based authentication. Rarely, [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) is used for storing information associated with the signed-in state. Session storage is specific to a particular domain and is not persisted across page loads. Playwright does not provide API to persist session storage, but the following snippet can be used to save/load session storage.
Reusing authenticated state covers [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) and [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) based authentication. Rarely, [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) is used for storing information associated with the signed-in state. Session storage is specific to a particular domain and is not persisted across page loads. Playwright does not provide API to persist session storage, but the following snippet can be used to save/load session storage.

```csharp
// Get session storage and store as env variable
Expand Down
4 changes: 2 additions & 2 deletions dotnet/docs/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pwsh bin/Debug/netX/playwright.ps1 codegen --timezone="Europe/Rome" --geolocatio

### Preserve authenticated state

Run `codegen` with `--save-storage` to save [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) at the end of the session. This is useful to separately record an authentication step and reuse it later when recording more tests.
Run `codegen` with `--save-storage` to save [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) data at the end of the session. This is useful to separately record an authentication step and reuse it later when recording more tests.

```bash
pwsh bin/Debug/netX/playwright.ps1 codegen github.com/microsoft/playwright --save-storage=auth.json
Expand All @@ -125,7 +125,7 @@ Make sure you only use the `auth.json` locally as it contains sensitive informat

#### Load authenticated state

Run with `--load-storage` to consume the previously loaded storage from the `auth.json`. This way, all [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) will be restored, bringing most web apps to the authenticated state without the need to login again. This means you can continue generating tests from the logged in state.
Run with `--load-storage` to consume the previously loaded storage from the `auth.json`. This way, all [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) data will be restored, bringing most web apps to the authenticated state without the need to login again. This means you can continue generating tests from the logged in state.

```bash
pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json github.com/microsoft/playwright
Expand Down
2 changes: 1 addition & 1 deletion java/docs/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ BrowserContext.setOffline(offline);

<font size="2" style={{position: "relative", top: "-20px"}}>Added before v1.9</font><x-search>browserContext.storageState</x-search>

Returns storage state for this browser context, contains current cookies and local storage snapshot.
Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot.

**Usage**

Expand Down
6 changes: 3 additions & 3 deletions java/docs/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ Redoing login for every test can slow down test execution. To mitigate that, reu

Playwright provides a way to reuse the signed-in state in the tests. That way you can log in only once and then skip the log in step for all of the tests.

Web apps use cookie-based or token-based authentication, where authenticated state is stored as [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) or in [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage). Playwright provides [BrowserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) method that can be used to retrieve storage state from authenticated contexts and then create new contexts with prepopulated state.
Web apps use cookie-based or token-based authentication, where authenticated state is stored as [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), in [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) or in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API). Playwright provides [BrowserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) method that can be used to retrieve storage state from authenticated contexts and then create new contexts with prepopulated state.

Cookies and local storage state can be used across different browsers. They depend on your application's authentication model: some apps might require both cookies and local storage.
Cookies, local storage and IndexedDB state can be used across different browsers. They depend on your application's authentication model which may require some combination of cookies, local storage or IndexedDB.

The following code snippet retrieves state from an authenticated context and creates a new context with that state.

Expand All @@ -94,7 +94,7 @@ BrowserContext context = browser.newContext(

### Session storage

Reusing authenticated state covers [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) based authentication. Rarely, [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) is used for storing information associated with the signed-in state. Session storage is specific to a particular domain and is not persisted across page loads. Playwright does not provide API to persist session storage, but the following snippet can be used to save/load session storage.
Reusing authenticated state covers [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) and [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) based authentication. Rarely, [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) is used for storing information associated with the signed-in state. Session storage is specific to a particular domain and is not persisted across page loads. Playwright does not provide API to persist session storage, but the following snippet can be used to save/load session storage.

```java
// Get session storage and store as env variable
Expand Down
4 changes: 2 additions & 2 deletions java/docs/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args='co

### Preserve authenticated state

Run `codegen` with `--save-storage` to save [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) at the end of the session. This is useful to separately record an authentication step and reuse it later when recording more tests.
Run `codegen` with `--save-storage` to save [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) data at the end of the session. This is useful to separately record an authentication step and reuse it later when recording more tests.

```bash
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen github.com/microsoft/playwright --save-storage=auth.json"
Expand All @@ -125,7 +125,7 @@ Make sure you only use the `auth.json` locally as it contains sensitive informat

#### Load authenticated state

Run with `--load-storage` to consume the previously loaded storage from the `auth.json`. This way, all [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) will be restored, bringing most web apps to the authenticated state without the need to login again. This means you can continue generating tests from the logged in state.
Run with `--load-storage` to consume the previously loaded storage from the `auth.json`. This way, all [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies), [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) data will be restored, bringing most web apps to the authenticated state without the need to login again. This means you can continue generating tests from the logged in state.

```bash
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen --load-storage=auth.json github.com/microsoft/playwright"
Expand Down
55 changes: 55 additions & 0 deletions nodejs/docs/api/class-apirequest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,61 @@ await apiRequest.newContext(options);



- `indexedDB` [Array]&lt;[Object]&gt; *(optional)*
- `name` [string]

database name
- `version` [number]

database version
- `stores` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `autoIncrement` [boolean]


- `indexes` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `unique` [boolean]


- `multiEntry` [boolean]



- `records` [Array]&lt;[Object]&gt;
- `key` [Object] *(optional)*


- `keyEncoded` [Object] *(optional)*

if `key` is not JSON-serializable, this contains an encoded version that preserves types.
- `value` [Object]


- `valueEncoded` [Object] *(optional)*

if `value` is not JSON-serializable, this contains an encoded version that preserves types.



indexedDB to set for context


Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) or [apiRequestContext.storageState()](/api/class-apirequestcontext.mdx#api-request-context-storage-state). Either a path to the file with saved storage, or the value returned by one of [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) or [apiRequestContext.storageState()](/api/class-apirequestcontext.mdx#api-request-context-storage-state) methods.
- `timeout` [number] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="api-request-new-context-option-timeout"/><a href="#api-request-new-context-option-timeout" class="list-anchor">#</a>
Expand Down
54 changes: 54 additions & 0 deletions nodejs/docs/api/class-apirequestcontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,60 @@ await apiRequestContext.storageState(options);



- `indexedDB` [Array]&lt;[Object]&gt;
- `name` [string]


- `version` [number]


- `stores` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `autoIncrement` [boolean]


- `indexes` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `unique` [boolean]


- `multiEntry` [boolean]



- `records` [Array]&lt;[Object]&gt;
- `key` [Object] *(optional)*


- `keyEncoded` [Object] *(optional)*

if `key` is not JSON-serializable, this contains an encoded version that preserves types.
- `value` [Object]


- `valueEncoded` [Object] *(optional)*

if `value` is not JSON-serializable, this contains an encoded version that preserves types.







Expand Down
120 changes: 114 additions & 6 deletions nodejs/docs/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,63 @@ If directly using this method to create [BrowserContext]s, it is best practice t
- `value` [string]



localStorage to set for context

localStorage to set for context
- `indexedDB` [Array]&lt;[Object]&gt; *(optional)*
- `name` [string]

database name
- `version` [number]

database version
- `stores` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `autoIncrement` [boolean]


- `indexes` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `unique` [boolean]


- `multiEntry` [boolean]



- `records` [Array]&lt;[Object]&gt;
- `key` [Object] *(optional)*


- `keyEncoded` [Object] *(optional)*

if `key` is not JSON-serializable, this contains an encoded version that preserves types.
- `value` [Object]


- `valueEncoded` [Object] *(optional)*

if `value` is not JSON-serializable, this contains an encoded version that preserves types.



indexedDB to set for context


Learn more about [storage state and auth](../auth.mdx).

Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state).
Expand Down Expand Up @@ -669,9 +723,63 @@ await browser.newPage(options);
- `value` [string]



localStorage to set for context

localStorage to set for context
- `indexedDB` [Array]&lt;[Object]&gt; *(optional)*
- `name` [string]

database name
- `version` [number]

database version
- `stores` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `autoIncrement` [boolean]


- `indexes` [Array]&lt;[Object]&gt;
- `name` [string]


- `keyPath` [string] *(optional)*


- `keyPathArray` [Array]&lt;[string]&gt; *(optional)*


- `unique` [boolean]


- `multiEntry` [boolean]



- `records` [Array]&lt;[Object]&gt;
- `key` [Object] *(optional)*


- `keyEncoded` [Object] *(optional)*

if `key` is not JSON-serializable, this contains an encoded version that preserves types.
- `value` [Object]


- `valueEncoded` [Object] *(optional)*

if `value` is not JSON-serializable, this contains an encoded version that preserves types.



indexedDB to set for context


Learn more about [storage state and auth](../auth.mdx).

Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state).
Expand Down
Loading
Loading