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-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ Returns locator to the last matching element.
**Usage**

```csharp
var banana = await page.GetByRole(AriaRole.Listitem).Last(1);
var banana = page.GetByRole(AriaRole.Listitem).Last;
```

**Returns**
Expand Down
4 changes: 1 addition & 3 deletions dotnet/docs/api/class-screencast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ Starts the screencast. When [Path](/api/class-screencast.mdx#screencast-start-op

Max frame height in pixels.

Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be smaller than these bounds. If not specified the size will be equal to page viewport scaled down to fit into 800×800.

A page is captured only once, and all consumers share that single capture. Tracing captures screenshots this way as well, so with tracing or the `recordVideo` context option already active this option is ignored, and both the frames and any recorded video use the size of the running capture.
Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be smaller than these bounds. If a screencast is already active (e.g. started by tracing or video recording), the existing configuration takes precedence and the frame size may exceed these bounds or this option may be ignored. If not specified the size will be equal to page viewport scaled down to fit into 800×800.

**Returns**
- [Disposable]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="screencast-start-return"/><a href="#screencast-start-return" class="list-anchor">#</a>
Expand Down
8 changes: 8 additions & 0 deletions dotnet/docs/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ Run `codegen` with `--user-data-dir` to set a fixed [user data directory](https:
pwsh bin/Debug/netX/playwright.ps1 codegen --user-data-dir=/path/to/your/browser/data/ github.com/microsoft/playwright
```

#### Authenticate with HTTP credentials

Run `codegen` with `--http-credentials` to authenticate with [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Authentication). Unlike credentials embedded in the URL, they are sent to any origin that requests them during the recording session and are included in the generated code.

```bash
pwsh bin/Debug/netX/playwright.ps1 codegen --http-credentials="username:password" example.com
```

## Record using custom setup

If you would like to use codegen in some non-standard setup (for example, use [BrowserContext.RouteAsync()](/api/class-browsercontext.mdx#browser-context-route)), it is possible to call [Page.PauseAsync()](/api/class-page.mdx#page-pause) that will open a separate window with codegen controls.
Expand Down
35 changes: 5 additions & 30 deletions dotnet/docs/getting-started-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,25 @@ Playwright comes with `playwright-cli`, a command-line interface for browser aut
## Prerequisites

Before you begin, make sure you have the following installed:
- Playwright for your language, **or** [Node.js](https://nodejs.org/) 20+ for the standalone `@playwright/cli` package
- [Node.js](https://nodejs.org/) 20 or newer
- A coding agent: Claude Code, GitHub Copilot, or similar

## Installation

Install the standalone CLI globally (works with any language):
Install `playwright-cli` globally:

```bash
npm install -g @playwright/cli@latest
playwright-cli --help
```

Or use the CLI bundled with your Playwright install:
Alternatively, install `@playwright/cli` as a local dependency and use `npx`:

```bash
# JavaScript / TypeScript
npx playwright cli --help

# Python
python -m playwright cli --help
npm install -D @playwright/cli@latest
npx playwright-cli --help
```

When using a bundled entry point, replace `playwright-cli` with `npx playwright cli` or `python -m playwright cli` in the commands below.

### Installing skills

Coding agents like Claude Code and GitHub Copilot can use locally installed skills for richer context about available commands:
Expand Down Expand Up @@ -300,29 +295,11 @@ playwright-cli attach --extension

This requires the [Playwright Extension](https://github.com/microsoft/playwright/blob/main/packages/extension/README.md) to be installed.

## Debugging tests

Coding agents can pause a test at the start, attach with `playwright-cli`, and explore the live browser — useful for diagnosing and fixing failures.

```bash
# JavaScript / TypeScript
PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
# → Debugging Instructions with session name, e.g. tw-abcdef
playwright-cli attach tw-abcdef

# Python (pytest-playwright; -s keeps the attach line visible)
pytest --playwright-debug=cli -s
playwright-cli attach tw-abcdef
```

Keep the test running in the background while you attach. The installed skill documents this workflow for agents.

## Quick Reference

| Action | Command |
| ------------------------- | --------------------------------------------------- |
| **Install CLI** | `npm install -g @playwright/cli@latest` |
| **Use bundled CLI** | `npx playwright cli …` / `python -m playwright cli …` |
| **Install skills** | `playwright-cli install --skills` |
| **Open a page** | `playwright-cli open https://example.com` |
| **Click an element** | `playwright-cli click e15` |
Expand All @@ -332,8 +309,6 @@ Keep the test running in the background while you attach. The installed skill do
| **Run headed** | `playwright-cli open https://example.com --headed` |
| **Use Firefox** | `playwright-cli open --browser=firefox` |
| **Monitor sessions** | `playwright-cli show` |
| **Debug JS test** | `npx playwright test --debug=cli` |
| **Debug Python test** | `pytest --playwright-debug=cli -s` |

## What's Next
- [Write tests using web-first assertions, page fixtures, and locators](./writing-tests.mdx)
Expand Down
16 changes: 15 additions & 1 deletion dotnet/docs/test-assertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import HTMLCard from '@site/src/components/HTMLCard';

## List of assertions
## Introduction

Playwright includes web-specific assertions that automatically retry until the expected condition is met. Consider the following example:

```csharp
await Expect(Page.GetByTestId("status")).ToHaveTextAsync("Submitted");
```

Playwright will re-test the element with the test ID of `status` until it has the `"Submitted"` text. It will re-fetch the element and check it repeatedly until the condition is met or the timeout is reached.

By default, the timeout for assertions is 5 seconds.

## Auto-retrying assertions

The following assertions will retry until the assertion passes or the assertion timeout is reached.

| Assertion | Description |
| :- | :- |
Expand Down
4 changes: 1 addition & 3 deletions java/docs/api/class-screencast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ Starts the screencast. When [setPath](/api/class-screencast.mdx#screencast-start

Max frame height in pixels.

Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be smaller than these bounds. If not specified the size will be equal to page viewport scaled down to fit into 800×800.

A page is captured only once, and all consumers share that single capture. Tracing captures screenshots this way as well, so with tracing or the `recordVideo` context option already active this option is ignored, and both the frames and any recorded video use the size of the running capture.
Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be smaller than these bounds. If a screencast is already active (e.g. started by tracing or video recording), the existing configuration takes precedence and the frame size may exceed these bounds or this option may be ignored. If not specified the size will be equal to page viewport scaled down to fit into 800×800.

**Returns**
- [Disposable]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="screencast-start-return"/><a href="#screencast-start-return" class="list-anchor">#</a>
Expand Down
8 changes: 8 additions & 0 deletions java/docs/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ Run `codegen` with `--user-data-dir` to set a fixed [user data directory](https:
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen --user-data-dir=/path/to/your/browser/data/ github.com/microsoft/playwright"
```

#### Authenticate with HTTP credentials

Run `codegen` with `--http-credentials` to authenticate with [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Authentication). Unlike credentials embedded in the URL, they are sent to any origin that requests them during the recording session and are included in the generated code.

```bash
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args='codegen --http-credentials="username:password" example.com'
```

## Record using custom setup

If you would like to use codegen in some non-standard setup (for example, use [BrowserContext.route()](/api/class-browsercontext.mdx#browser-context-route)), it is possible to call [Page.pause()](/api/class-page.mdx#page-pause) that will open a separate window with codegen controls.
Expand Down
35 changes: 5 additions & 30 deletions java/docs/getting-started-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,25 @@ Playwright comes with `playwright-cli`, a command-line interface for browser aut
## Prerequisites

Before you begin, make sure you have the following installed:
- Playwright for your language, **or** [Node.js](https://nodejs.org/) 20+ for the standalone `@playwright/cli` package
- [Node.js](https://nodejs.org/) 20 or newer
- A coding agent: Claude Code, GitHub Copilot, or similar

## Installation

Install the standalone CLI globally (works with any language):
Install `playwright-cli` globally:

```bash
npm install -g @playwright/cli@latest
playwright-cli --help
```

Or use the CLI bundled with your Playwright install:
Alternatively, install `@playwright/cli` as a local dependency and use `npx`:

```bash
# JavaScript / TypeScript
npx playwright cli --help

# Python
python -m playwright cli --help
npm install -D @playwright/cli@latest
npx playwright-cli --help
```

When using a bundled entry point, replace `playwright-cli` with `npx playwright cli` or `python -m playwright cli` in the commands below.

### Installing skills

Coding agents like Claude Code and GitHub Copilot can use locally installed skills for richer context about available commands:
Expand Down Expand Up @@ -300,29 +295,11 @@ playwright-cli attach --extension

This requires the [Playwright Extension](https://github.com/microsoft/playwright/blob/main/packages/extension/README.md) to be installed.

## Debugging tests

Coding agents can pause a test at the start, attach with `playwright-cli`, and explore the live browser — useful for diagnosing and fixing failures.

```bash
# JavaScript / TypeScript
PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
# → Debugging Instructions with session name, e.g. tw-abcdef
playwright-cli attach tw-abcdef

# Python (pytest-playwright; -s keeps the attach line visible)
pytest --playwright-debug=cli -s
playwright-cli attach tw-abcdef
```

Keep the test running in the background while you attach. The installed skill documents this workflow for agents.

## Quick Reference

| Action | Command |
| ------------------------- | --------------------------------------------------- |
| **Install CLI** | `npm install -g @playwright/cli@latest` |
| **Use bundled CLI** | `npx playwright cli …` / `python -m playwright cli …` |
| **Install skills** | `playwright-cli install --skills` |
| **Open a page** | `playwright-cli open https://example.com` |
| **Click an element** | `playwright-cli click e15` |
Expand All @@ -332,8 +309,6 @@ Keep the test running in the background while you attach. The installed skill do
| **Run headed** | `playwright-cli open https://example.com --headed` |
| **Use Firefox** | `playwright-cli open --browser=firefox` |
| **Monitor sessions** | `playwright-cli show` |
| **Debug JS test** | `npx playwright test --debug=cli` |
| **Debug Python test** | `pytest --playwright-debug=cli -s` |

## What's Next
- [Write tests using web-first assertions, page fixtures, and locators](./writing-tests.mdx)
Expand Down
2 changes: 1 addition & 1 deletion java/docs/mock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following code will intercept all the calls to `*/**/api/v1/fruits` and will

```java
// Intercept the route to the fruit API
page.route("https://fruit.ceo/api/breeds/image/random", route -> {
page.route("*/**/api/v1/fruits", route -> {
List<Dictionary<String, Object>> data = new ArrayList<Dictionary<String, Object>>();
Hashtable<String, Object> dict = new Hashtable<String, Object>();
dict.put("name", "Strawberry");
Expand Down
39 changes: 38 additions & 1 deletion java/docs/test-assertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import HTMLCard from '@site/src/components/HTMLCard';

## List of assertions
## Introduction

Playwright includes web-specific assertions that automatically retry until the expected condition is met. Consider the following example:

```java
assertThat(page.getByTestId("status")).hasText("Submitted");
```

Playwright will re-test the element with the test ID of `status` until it has the `"Submitted"` text. It will re-fetch the element and check it repeatedly until the condition is met or the timeout is reached.

By default, the timeout for assertions is 5 seconds.

## Auto-retrying assertions

The following assertions will retry until the assertion passes or the assertion timeout is reached.

| Assertion | Description |
| :- | :- |
Expand Down Expand Up @@ -39,6 +53,29 @@ import HTMLCard from '@site/src/components/HTMLCard';
| [assertThat(page).hasURL()](/api/class-pageassertions.mdx#page-assertions-to-have-url) | Page has a URL |
| [assertThat(response).isOK()](/api/class-apiresponseassertions.mdx#api-response-assertions-to-be-ok) | Response has an OK status |

## Setting a custom timeout

You can specify a custom timeout for assertions either globally or per assertion. The default timeout is 5 seconds.

### Global timeout

```java
import com.microsoft.playwright.assertions.PlaywrightAssertions;

PlaywrightAssertions.setDefaultAssertionTimeout(10_000);
```

### Per assertion timeout

```java
import com.microsoft.playwright.assertions.LocatorAssertions;

import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;

assertThat(page.getByText("Name")).isVisible(
new LocatorAssertions.IsVisibleOptions().setTimeout(10_000));
```


[APIRequest]: /api/class-apirequest.mdx "APIRequest"
[APIRequestContext]: /api/class-apirequestcontext.mdx "APIRequestContext"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/accessibility-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ test('example using custom fixture', async ({ page, makeAxeBuilder }) => {
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ For example, consider a scenario where Playwright will click `Sign Up` button re
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ test('global context request has isolated cookie storage', async ({
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ android.setDefaultTimeout(timeout);
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-androiddevice.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,6 @@ androidDevice.on('webview', data => {});
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-androidinput.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ await androidInput.type(text);
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-androidsocket.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ androidSocket.on('data', data => {});
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-androidwebview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ androidWebView.on('close', data => {});
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-apirequest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ await apiRequest.newContext(options);
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-apirequestcontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ apiRequestContext.tracing
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-apiresponse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ apiResponse.url();
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
1 change: 0 additions & 1 deletion nodejs/docs/api/class-apiresponseassertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ await expect(response).not.toBeOK();
[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext"
[BrowserServer]: /api/class-browserserver.mdx "BrowserServer"
[BrowserType]: /api/class-browsertype.mdx "BrowserType"
[By]: /api/class-by.mdx "By"
[CDPSession]: /api/class-cdpsession.mdx "CDPSession"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
Expand Down
Loading