Soenneker.Playwrights.TestHosts 11.0.370

Prefix Reserved
dotnet add package Soenneker.Playwrights.TestHosts --version 11.0.370
                    
NuGet\Install-Package Soenneker.Playwrights.TestHosts -Version 11.0.370
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Playwrights.TestHosts" Version="11.0.370" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Playwrights.TestHosts" Version="11.0.370" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Playwrights.TestHosts" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Playwrights.TestHosts --version 11.0.370
                    
#r "nuget: Soenneker.Playwrights.TestHosts, 11.0.370"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Playwrights.TestHosts@11.0.370
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Playwrights.TestHosts&version=11.0.370
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Playwrights.TestHosts&version=11.0.370
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.370 81 11/20/2026
11.0.369 94 11/19/2026
11.0.368 110 11/19/2026
11.0.367 103 11/19/2026
11.0.366 92 11/19/2026
11.0.365 99 11/19/2026
11.0.363 106 11/18/2026
11.0.362 102 11/18/2026
11.0.361 89 11/18/2026
11.0.360 100 11/18/2026
11.0.359 105 11/18/2026
11.0.358 119 11/17/2026
11.0.357 121 11/17/2026
11.0.356 114 11/15/2026
11.0.355 101 11/15/2026
11.0.354 104 11/15/2026
11.0.353 103 11/15/2026
11.0.352 111 11/13/2026
11.0.351 122 11/12/2026
11.0.350 104 11/12/2026
Loading failed

Updated Soenneker.TestHosts.Unit to 11.0.245