You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Playwright](https://playwright.dev/) is a framework for web testing and automation. It allows testing across all modern rendering engines including Chromium, WebKit, and Firefox with a single API. This module provides pre-configured browser containers for automated testing.
4
+
5
+
Add the following dependency to your project file:
6
+
7
+
```shell title="NuGet"
8
+
dotnet add package Testcontainers.Playwright
9
+
```
10
+
11
+
You can start a Playwright container instance from any .NET application. To create and start a container instance with the default configuration, use the module-specific builder as shown below:
12
+
13
+
=== "Start a Playwright container"
14
+
```csharp
15
+
var playwrightContainer = new PlaywrightBuilder().Build();
16
+
await playwrightContainer.StartAsync();
17
+
```
18
+
19
+
This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method.
20
+
21
+
This example demonstrates the Playwright container accessing a web site running inside another container (using the [`testcontainers/helloworld`](https://github.com/testcontainers/helloworld) image). Both containers are assigned to a shared network (see the [Network configuration](#network-configuration) section) to enable communication between them.
To execute the tests, use the command `dotnet test` from a terminal.
36
+
37
+
--8<-- "docs/modules/_call_out_test_projects.txt"
38
+
39
+
## Network configuration
40
+
41
+
The Playwright container is configured with a network that can be shared with other containers. This is useful when testing applications that need to communicate with other services. Use the `GetNetwork()` method to access the container's network:
0 commit comments