Soenneker.Playwrights.TestHosts
4.0.280
Prefix Reserved
dotnet add package Soenneker.Playwrights.TestHosts --version 4.0.280
NuGet\Install-Package Soenneker.Playwrights.TestHosts -Version 4.0.280
<PackageReference Include="Soenneker.Playwrights.TestHosts" Version="4.0.280" />
<PackageVersion Include="Soenneker.Playwrights.TestHosts" Version="4.0.280" />
<PackageReference Include="Soenneker.Playwrights.TestHosts" />
paket add Soenneker.Playwrights.TestHosts --version 4.0.280
#r "nuget: Soenneker.Playwrights.TestHosts, 4.0.280"
#:package Soenneker.Playwrights.TestHosts@4.0.280
#addin nuget:?package=Soenneker.Playwrights.TestHosts&version=4.0.280
#tool nuget:?package=Soenneker.Playwrights.TestHosts&version=4.0.280
Soenneker.Playwrights.TestHosts
A reusable test fixture that locates an application project, starts it on an available loopback port, and provides Playwright browser sessions to the suite.
Installation
dotnet add package Soenneker.Playwrights.TestHosts
Define a host
Derive from PlaywrightHostedTestHost and identify the solution and application project. The project path must be relative to, and remain inside, the discovered solution directory.
using System.IO;
using Soenneker.Playwrights.TestEnvironment.Options;
using Soenneker.Playwrights.TestHosts;
public sealed class AppPlaywrightHost : PlaywrightHostedTestHost
{
protected override PlaywrightTestHostOptions CreateOptions()
{
return new PlaywrightTestHostOptions
{
SolutionFileName = "MyApp.slnx",
ProjectRelativePath = Path.Combine("src", "MyApp", "MyApp.csproj"),
ApplicationName = "MyApp",
Restore = false,
Build = true,
BuildConfiguration = "Debug",
ReuseBrowserContextAcrossSessions = false,
ReusePageAcrossSessions = false
};
}
}
Override ConfigureServices when the test fixture needs additional dependencies:
protected override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<TestData>();
}
Use it in tests
Share the host for the test session, then create and dispose a browser session in each test:
using Microsoft.Playwright;
using Soenneker.Playwrights.Session;
[ClassDataSource<AppPlaywrightHost>(Shared = SharedType.PerTestSession)]
public sealed class HomePageTests
{
private readonly AppPlaywrightHost _host;
public HomePageTests(AppPlaywrightHost host)
{
_host = host;
}
[Test]
public async ValueTask Home_page_loads()
{
await using BrowserSession session = await _host.CreateSession();
await session.Page.GotoAsync(_host.BaseUrl);
await Assertions.Expect(session.Page.GetByRole(AriaRole.Heading))
.ToBeVisibleAsync();
}
}
BaseUrl and CreateSession are available after the shared host initializes. Disposing the host closes Playwright and terminates the application process. Shared context/page behavior can be set in CreateOptions or overridden per CreateSession call with PlaywrightSessionOptions.
| 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
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Logging.Console (>= 10.0.12)
- Serilog.Extensions.Hosting (>= 10.0.0)
- Soenneker.Extensions.ValueTask (>= 4.0.124)
- Soenneker.Playwrights.TestEnvironment (>= 4.0.290)
- Soenneker.TestHosts.Unit (>= 4.0.182)
- Soenneker.Utils.Test (>= 4.0.331)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Playwrights.TestHosts:
| Package | Downloads |
|---|---|
|
Soenneker.Playwrights.Tests.Unit
A fixtured unit test for testing with Playwright |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.280 | 29 | 10/9/2026 |
| 4.0.279 | 90 | 10/8/2026 |
| 4.0.278 | 100 | 10/6/2026 |
| 4.0.277 | 111 | 10/5/2026 |
| 4.0.276 | 127 | 10/3/2026 |
| 4.0.275 | 110 | 10/1/2026 |
| 4.0.273 | 133 | 9/30/2026 |
| 4.0.272 | 98 | 9/30/2026 |
| 4.0.271 | 100 | 9/30/2026 |
| 4.0.270 | 108 | 9/30/2026 |
| 4.0.269 | 100 | 9/30/2026 |
| 4.0.268 | 100 | 9/29/2026 |
| 4.0.267 | 99 | 9/29/2026 |
| 4.0.266 | 126 | 9/27/2026 |
| 4.0.265 | 103 | 9/27/2026 |
| 4.0.264 | 105 | 9/26/2026 |
| 4.0.263 | 132 | 9/25/2026 |
| 4.0.262 | 95 | 9/25/2026 |
| 4.0.261 | 94 | 9/25/2026 |
| 4.0.260 | 100 | 9/25/2026 |