Soenneker.Playwrights.TestEnvironment
4.0.196
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Playwrights.TestEnvironment --version 4.0.196
NuGet\Install-Package Soenneker.Playwrights.TestEnvironment -Version 4.0.196
<PackageReference Include="Soenneker.Playwrights.TestEnvironment" Version="4.0.196" />
<PackageVersion Include="Soenneker.Playwrights.TestEnvironment" Version="4.0.196" />
<PackageReference Include="Soenneker.Playwrights.TestEnvironment" />
paket add Soenneker.Playwrights.TestEnvironment --version 4.0.196
#r "nuget: Soenneker.Playwrights.TestEnvironment, 4.0.196"
#:package Soenneker.Playwrights.TestEnvironment@4.0.196
#addin nuget:?package=Soenneker.Playwrights.TestEnvironment&version=4.0.196
#tool nuget:?package=Soenneker.Playwrights.TestEnvironment&version=4.0.196
Soenneker.Playwrights.TestEnvironment
Runs an ASP.NET Core project on an available loopback port and provides headless Playwright sessions for integration tests.
Installation
dotnet add package Soenneker.Playwrights.TestEnvironment
Registration
Register the host options and environment in the test service collection:
using Microsoft.Extensions.DependencyInjection;
using Soenneker.Playwrights.TestEnvironment.Options;
using Soenneker.Playwrights.TestEnvironment.Registrars;
services.AddSingleton(new PlaywrightTestHostOptions
{
SolutionFileName = "MyApp.slnx",
ProjectRelativePath = "src/MyApp/MyApp.csproj",
ApplicationName = "MyApp",
Restore = true,
Build = true,
BuildConfiguration = "Release"
});
services.AddPlaywrightTestEnvironmentAsSingleton();
Use the singleton registration for a test host shared by the suite. AddPlaywrightTestEnvironmentAsScoped() gives each scope its own mutable host runtime, while the Playwright installer and HTTP transport remain process-wide singletons.
Start the application and create a session
using Soenneker.Playwrights.TestEnvironment.Abstract;
IPlaywrightTestEnvironment environment =
serviceProvider.GetRequiredService<IPlaywrightTestEnvironment>();
await environment.Initialize(
@"C:\git\MyApp\src\MyApp\MyApp.csproj",
cancellationToken);
await using var session = await environment.CreateSession(cancellationToken: cancellationToken);
await session.Page.GotoAsync("/");
await Assertions.Expect(session.Page.GetByRole(AriaRole.Heading))
.ToBeVisibleAsync();
Initialize installs the configured Playwright browser if needed, starts Chromium, launches the project at BaseUrl, and waits until the application accepts HTTP requests. Dispose the environment to close Playwright and terminate the application process.
Session reuse
Sessions get their own context and page unless reuse is enabled:
services.AddSingleton(new PlaywrightTestHostOptions
{
SolutionFileName = "MyApp.slnx",
ProjectRelativePath = "src/MyApp/MyApp.csproj",
ReuseBrowserContextAcrossSessions = true,
ReusePageAcrossSessions = false
});
Per-session overrides take precedence over the host defaults:
await using var session = await environment.CreateSession(
new PlaywrightSessionOptions
{
ReuseBrowserContextAcrossSessions = true,
ReusePageAcrossSessions = false
},
cancellationToken);
Reusing a page implies reusing its context. A session does not dispose shared pages or contexts; the environment owns and releases them.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.Playwrights.Installation (>= 4.0.140)
- Soenneker.Playwrights.Session (>= 4.0.14)
- Soenneker.Utils.Delay (>= 4.0.82)
- Soenneker.Utils.Dotnet (>= 4.0.2519)
- Soenneker.Utils.HttpClientCache (>= 4.0.2031)
- Soenneker.Utils.Network (>= 4.0.1217)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Playwrights.TestEnvironment:
| Package | Downloads |
|---|---|
|
Soenneker.Playwrights.TestHosts
A test host for automated testing with Playwright |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.201 | 0 | 8/31/2026 |
| 4.0.200 | 0 | 8/31/2026 |
| 4.0.199 | 0 | 8/31/2026 |
| 4.0.198 | 0 | 8/31/2026 |
| 4.0.197 | 36 | 8/31/2026 |
| 4.0.196 | 32 | 8/31/2026 |
| 4.0.195 | 31 | 8/30/2026 |
| 4.0.194 | 38 | 8/30/2026 |
| 4.0.193 | 66 | 8/30/2026 |
| 4.0.192 | 37 | 8/30/2026 |
| 4.0.191 | 62 | 8/30/2026 |
| 4.0.190 | 38 | 8/29/2026 |
| 4.0.189 | 43 | 8/29/2026 |
| 4.0.188 | 40 | 8/29/2026 |
| 4.0.187 | 169 | 8/26/2026 |
| 4.0.186 | 86 | 8/26/2026 |
| 4.0.185 | 65 | 8/26/2026 |
| 4.0.184 | 88 | 8/26/2026 |
| 4.0.183 | 99 | 8/26/2026 |
| 4.0.182 | 158 | 8/22/2026 |