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
10 changes: 10 additions & 0 deletions dotnet/docs/api/class-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,11 @@ Returns the main resource response. In case of multiple redirects, the navigatio

Navigate to the previous page in history.

:::warning

**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state.
:::

**Usage**

```csharp
Expand Down Expand Up @@ -1246,6 +1251,11 @@ Returns the main resource response. In case of multiple redirects, the navigatio

Navigate to the next page in history.

:::warning

**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state.
:::

**Usage**

```csharp
Expand Down
10 changes: 10 additions & 0 deletions dotnet/docs/navigations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ await page.GetByText("Click me").ClickAsync();
await page.WaitForURL("**/login");
```

## Back/Forward Cache (BFCache)

Modern browsers utilize a Back/Forward Cache (BFCache) to instantly load a page when a user navigates back or forward. This is achieved by freezing the page's DOM and JavaScript heap in memory, and thawing it upon return.

By default, Playwright disables the BFCache across all browsers to ensure consistent, clean testing environments.

Even if you explicitly enable BFCache, **testing BFCache restorations is not supported**. Because a BFCache restore skips the network fetch phase, the browser does not fire standard navigation lifecycle events (such as `commit`, `domcontentloaded`, or `load`). Playwright's internal `Page` state heavily relies on these network-level events to stay synchronized.

Consequently, triggering a BFCache restore (e.g., via `page.goBack()`) will bypass Playwright's lifecycle tracking, resulting in timeouts and a completely desynchronized `Page` object where subsequent interactions will fail.

## Navigation events

Playwright splits the process of showing a new document in a page into **navigation** and **loading**.
Expand Down
10 changes: 10 additions & 0 deletions java/docs/api/class-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,11 @@ Returns the main resource response. In case of multiple redirects, the navigatio

Navigate to the previous page in history.

:::warning

**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state.
:::

**Usage**

```java
Expand Down Expand Up @@ -1251,6 +1256,11 @@ Returns the main resource response. In case of multiple redirects, the navigatio

Navigate to the next page in history.

:::warning

**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state.
:::

**Usage**

```java
Expand Down
10 changes: 10 additions & 0 deletions java/docs/navigations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ page.getByText("Click me").click();
page.waitForURL("**/login");
```

## Back/Forward Cache (BFCache)

Modern browsers utilize a Back/Forward Cache (BFCache) to instantly load a page when a user navigates back or forward. This is achieved by freezing the page's DOM and JavaScript heap in memory, and thawing it upon return.

By default, Playwright disables the BFCache across all browsers to ensure consistent, clean testing environments.

Even if you explicitly enable BFCache, **testing BFCache restorations is not supported**. Because a BFCache restore skips the network fetch phase, the browser does not fire standard navigation lifecycle events (such as `commit`, `domcontentloaded`, or `load`). Playwright's internal `Page` state heavily relies on these network-level events to stay synchronized.

Consequently, triggering a BFCache restore (e.g., via `page.goBack()`) will bypass Playwright's lifecycle tracking, resulting in timeouts and a completely desynchronized `Page` object where subsequent interactions will fail.

## Navigation events

Playwright splits the process of showing a new document in a page into **navigation** and **loading**.
Expand Down
4 changes: 4 additions & 0 deletions nodejs/docs/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ The order of evaluation of multiple scripts installed via [browserContext.addIni
- `arg` [Serializable] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-init-script-option-arg"/><a href="#browser-context-add-init-script-option-arg" class="list-anchor">#</a>

Optional argument to pass to [script](/api/class-browsercontext.mdx#browser-context-add-init-script-option-script) (only supported when passing a function).
- `options` [Object] *(optional)*
- `exposeFunctions` [boolean] *(optional)* <font size="2">Added in: v1.62</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-init-script-option-expose-functions"/><a href="#browser-context-add-init-script-option-expose-functions" class="list-anchor">#</a>

When set to `true`, functions passed inside [arg](/api/class-browsercontext.mdx#browser-context-add-init-script-option-arg) are exposed in the page and can be called from the init script. Calling one returns a [Promise] of its result. Under the hood, each function is exposed via [page.exposeFunction()](/api/class-page.mdx#page-expose-function), so it is technically accessible from all frames and worlds of the page. Unlike functions passed to [page.evaluate()](/api/class-page.mdx#page-evaluate), functions passed to an init script are exposed in every new document, so they survive navigations. Defaults to `false`, in which case functions are not serializable and are silently dropped.

**Returns**
- [Promise]&lt;[Disposable]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-init-script-return"/><a href="#browser-context-add-init-script-return" class="list-anchor">#</a>
Expand Down
4 changes: 2 additions & 2 deletions nodejs/docs/api/class-cdpsession.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ Emitted for every CDP event received from the session. Allows subscribing to all
**Usage**

```js
session.on('event', ({ name, params }) => {
console.log(`CDP event: ${name}`, params);
session.on('event', ({ method, params }) => {
console.log(`CDP event: ${method}`, params);
});
```

Expand Down
48 changes: 48 additions & 0 deletions nodejs/docs/api/class-fixtures.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,54 @@ Given the test above, Playwright Test will set up the `page` fixture before runn
Playwright Test comes with builtin fixtures listed below, and you can add your own fixtures as well. Playwright Test also [provides options][TestOptions] to configure [fixtures.browser](/api/class-fixtures.mdx#fixtures-browser), [fixtures.context](/api/class-fixtures.mdx#fixtures-context) and [fixtures.page](/api/class-fixtures.mdx#fixtures-page).


---

## Methods

### mount {/* #fixtures-mount */}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.62</font><x-search>fixtures.mount</x-search>

Mounts a component story and returns a [Locator] pointing to the root element the story was rendered into. Scope your queries from the returned locator: `component.getByRole('button')`, not `page.getByRole('button')`.

A **story** is a small wrapper component that embeds the component under test in one specific scenario: hard-coded props, mock data, providers, recorded callbacks. Stories are rendered by a **gallery** page that you implement and serve at [testOptions.baseURL](/api/class-testoptions.mdx#test-options-base-url). The gallery exposes `window.mount(params)` and `window.unmount()` functions that render a story into its root element. Each call to [fixtures.mount()](/api/class-fixtures.mdx#fixtures-mount) navigates to [testOptions.baseURL](/api/class-testoptions.mdx#test-options-base-url) and calls `window.mount()` with the story id and props, so tests are fully isolated from each other.

**Usage**

```js
test('click should expand', async ({ mount }) => {
const component = await mount('components/Expandable/Stateful');
await component.getByRole('button').click();
await expect(component.getByTestId('expanded')).toHaveValue('true');
});
```

Pass the story type as a template argument to type-check the props:

```js
import type { WithTitle } from './Button.story';

test('renders the title', async ({ mount }) => {
const component = await mount<typeof WithTitle>('Button/WithTitle', { title: 'Hello' });
await expect(component).toContainText('Hello');
});
```

The returned locator is augmented with two methods:
* `update(props)` - re-renders the same story with new props without remounting, preserving component state;
* `unmount()` - unmounts the story.

**Arguments**
- `storyId` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="fixtures-mount-option-story-id"/><a href="#fixtures-mount-option-story-id" class="list-anchor">#</a>

Identifier of the story to mount, as resolved by the gallery page. Conventionally, the story file path plus the exported story name, for example `'components/Button/Primary'`.
- `props` [Object] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="fixtures-mount-option-props"/><a href="#fixtures-mount-option-props" class="list-anchor">#</a>

Optional plain, serializable props passed to the story.

**Returns**
- [Locator]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="fixtures-mount-return"/><a href="#fixtures-mount-return" class="list-anchor">#</a>

---

## Properties
Expand Down
4 changes: 2 additions & 2 deletions nodejs/docs/api/class-frame.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ await bodyHandle.dispose();
- `options` [Object] *(optional)*
- `exposeFunctions` [boolean] *(optional)* <font size="2">Added in: v1.62</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-evaluate-option-expose-functions"/><a href="#frame-evaluate-option-expose-functions" class="list-anchor">#</a>

When set to `true`, functions passed inside [arg](/api/class-frame.mdx#frame-evaluate-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. The page-side functions are scoped to the execution context they were passed to and disappear when the page navigates. Defaults to `false`, in which case functions are not serializable and passing one throws an error, as before.
When set to `true`, functions passed inside [arg](/api/class-frame.mdx#frame-evaluate-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. Under the hood, each function is exposed via [page.exposeFunction()](/api/class-page.mdx#page-expose-function), so it is technically accessible from all frames and worlds of the page. Exposed functions are cleared upon the top-level navigation. Defaults to `false`, in which case functions are not serializable and passing one throws an error.

**Returns**
- [Promise]&lt;[Serializable]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-evaluate-return"/><a href="#frame-evaluate-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -304,7 +304,7 @@ await resultHandle.dispose();
- `options` [Object] *(optional)*
- `exposeFunctions` [boolean] *(optional)* <font size="2">Added in: v1.62</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-evaluate-handle-option-expose-functions"/><a href="#frame-evaluate-handle-option-expose-functions" class="list-anchor">#</a>

When set to `true`, functions passed inside [arg](/api/class-frame.mdx#frame-evaluate-handle-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. The page-side functions are scoped to the execution context they were passed to and disappear when the page navigates. Defaults to `false`, in which case functions are not serializable and passing one throws an error, as before.
When set to `true`, functions passed inside [arg](/api/class-frame.mdx#frame-evaluate-handle-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. Under the hood, each function is exposed via [page.exposeFunction()](/api/class-page.mdx#page-expose-function), so it is technically accessible from all frames and worlds of the page. Exposed functions are cleared upon the top-level navigation. Defaults to `false`, in which case functions are not serializable and passing one throws an error.

**Returns**
- [Promise]&lt;[JSHandle]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-evaluate-handle-return"/><a href="#frame-evaluate-handle-return" class="list-anchor">#</a>
Expand Down
4 changes: 2 additions & 2 deletions nodejs/docs/api/class-jshandle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10 retweets');
- `options` [Object] *(optional)*
- `exposeFunctions` [boolean] *(optional)* <font size="2">Added in: v1.62</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="js-handle-evaluate-option-expose-functions"/><a href="#js-handle-evaluate-option-expose-functions" class="list-anchor">#</a>

When set to `true`, functions passed inside [arg](/api/class-jshandle.mdx#js-handle-evaluate-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. The page-side functions are scoped to the execution context they were passed to and disappear when the page navigates. Defaults to `false`, in which case functions are not serializable and passing one throws an error, as before.
When set to `true`, functions passed inside [arg](/api/class-jshandle.mdx#js-handle-evaluate-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. Under the hood, each function is exposed via [page.exposeFunction()](/api/class-page.mdx#page-expose-function), so it is technically accessible from all frames and worlds of the page. Exposed functions are cleared upon the top-level navigation. Defaults to `false`, in which case functions are not serializable and passing one throws an error.

**Returns**
- [Promise]&lt;[Serializable]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="js-handle-evaluate-return"/><a href="#js-handle-evaluate-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -122,7 +122,7 @@ await jsHandle.evaluateHandle(pageFunction, arg, options);
- `options` [Object] *(optional)*
- `exposeFunctions` [boolean] *(optional)* <font size="2">Added in: v1.62</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="js-handle-evaluate-handle-option-expose-functions"/><a href="#js-handle-evaluate-handle-option-expose-functions" class="list-anchor">#</a>

When set to `true`, functions passed inside [arg](/api/class-jshandle.mdx#js-handle-evaluate-handle-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. The page-side functions are scoped to the execution context they were passed to and disappear when the page navigates. Defaults to `false`, in which case functions are not serializable and passing one throws an error, as before.
When set to `true`, functions passed inside [arg](/api/class-jshandle.mdx#js-handle-evaluate-handle-option-arg) are exposed in the page and can be called from the page function. Calling one returns a [Promise] of its result. Under the hood, each function is exposed via [page.exposeFunction()](/api/class-page.mdx#page-expose-function), so it is technically accessible from all frames and worlds of the page. Exposed functions are cleared upon the top-level navigation. Defaults to `false`, in which case functions are not serializable and passing one throws an error.

**Returns**
- [Promise]&lt;[JSHandle]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="js-handle-evaluate-handle-return"/><a href="#js-handle-evaluate-handle-return" class="list-anchor">#</a>
Expand Down
Loading
Loading