Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(roll): roll to ToT Playwright (roll/next-13-12-24) #1625

Merged
merged 1 commit into from
Dec 13, 2024
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
36 changes: 36 additions & 0 deletions dotnet/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,42 @@ Using `--ipc=host` is recommended when using Chrome ([Docker docs](https://docs.

See our [Continuous Integration guides](./ci.mdx) for sample configs.

### Remote Connection

You can run Playwright Server in Docker while keeping your tests running on the host system or another machine. This is useful for running tests on unsupported Linux distributions or remote execution scenarios.

#### Running the Playwright Server

Start the Playwright Server in Docker:

```bash
docker run -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.0-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

#### Connecting to the Server

```csharp
using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.ConnectAsync("ws://127.0.0.1:3000/");
```

#### Network Configuration

If you need to access local servers from within the Docker container:

```bash
docker run --add-host=hostmachine:host-gateway -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.0-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

This makes `hostmachine` point to the host's localhost. Your tests should use `hostmachine` instead of `localhost` when accessing local servers.

:::note

When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container.
:::

## Image tags

See [all available image tags].
Expand Down
44 changes: 44 additions & 0 deletions java/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,50 @@ Using `--ipc=host` is recommended when using Chrome ([Docker docs](https://docs.

See our [Continuous Integration guides](./ci.mdx) for sample configs.

### Remote Connection

You can run Playwright Server in Docker while keeping your tests running on the host system or another machine. This is useful for running tests on unsupported Linux distributions or remote execution scenarios.

#### Running the Playwright Server

Start the Playwright Server in Docker:

```bash
docker run -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.0-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

#### Connecting to the Server

```java
package org.example;

import com.microsoft.playwright.*;
import java.nio.file.Paths;

public class App {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().connect("ws://127.0.0.1:3000/");
}
}
}
```

#### Network Configuration

If you need to access local servers from within the Docker container:

```bash
docker run --add-host=hostmachine:host-gateway -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.0-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

This makes `hostmachine` point to the host's localhost. Your tests should use `hostmachine` instead of `localhost` when accessing local servers.

:::note

When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container.
:::

## Image tags

See [all available image tags].
Expand Down
42 changes: 42 additions & 0 deletions nodejs/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,48 @@ Using `--ipc=host` is recommended when using Chrome ([Docker docs](https://docs.

See our [Continuous Integration guides](./ci.mdx) for sample configs.

### Remote Connection

You can run Playwright Server in Docker while keeping your tests running on the host system or another machine. This is useful for running tests on unsupported Linux distributions or remote execution scenarios.

#### Running the Playwright Server

Start the Playwright Server in Docker:

```bash
docker run -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.1-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

#### Connecting to the Server

There are two ways to connect to the remote Playwright server:
1. Using environment variable with `@playwright/test`:

```bash
PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:3000/ npx playwright test
```

2. Using the [browserType.connect()](/api/class-browsertype.mdx#browser-type-connect) API for other applications:

```js
const browser = await playwright['chromium'].connect('ws://127.0.0.1:3000/');
```

#### Network Configuration

If you need to access local servers from within the Docker container:

```bash
docker run --add-host=hostmachine:host-gateway -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.1-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

This makes `hostmachine` point to the host's localhost. Your tests should use `hostmachine` instead of `localhost` when accessing local servers.

:::note

When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container.
:::

## Image tags

See [all available image tags].
Expand Down
59 changes: 59 additions & 0 deletions python/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,65 @@ Using `--ipc=host` is recommended when using Chrome ([Docker docs](https://docs.

See our [Continuous Integration guides](./ci.mdx) for sample configs.

### Remote Connection

You can run Playwright Server in Docker while keeping your tests running on the host system or another machine. This is useful for running tests on unsupported Linux distributions or remote execution scenarios.

#### Running the Playwright Server

Start the Playwright Server in Docker:

```bash
docker run -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.1-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

#### Connecting to the Server

<Tabs
groupId="python-flavor"
defaultValue="sync"
values={[
{label: 'Sync', value: 'sync'},
{label: 'Async', value: 'async'}
]
}>
<TabItem value="sync">

```py
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
browser = p.chromium.connect("ws://127.0.0.1:3000/")
```

</TabItem>
<TabItem value="async">

```py
from playwright.async_api import async_playwright

async with async_playwright() as p:
browser = await p.chromium.connect("ws://127.0.0.1:3000/")
```

</TabItem>
</Tabs>

#### Network Configuration

If you need to access local servers from within the Docker container:

```bash
docker run --add-host=hostmachine:host-gateway -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.49.1-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
```

This makes `hostmachine` point to the host's localhost. Your tests should use `hostmachine` instead of `localhost` when accessing local servers.

:::note

When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container.
:::

## Image tags

See [all available image tags].
Expand Down
Loading