Soenneker.Playwrights.TestHosts 11.0.352

Prefix Reserved
dotnet add package Soenneker.Playwrights.TestHosts --version 11.0.352
                    
NuGet\Install-Package Soenneker.Playwrights.TestHosts -Version 11.0.352
                    
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.352" />
                    
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.352" />
                    
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.352
                    
#r "nuget: Soenneker.Playwrights.TestHosts, 11.0.352"
                    
#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.352
                    
#: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.352
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Playwrights.TestHosts&version=11.0.352
                    
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.352 56 11/13/2026
11.0.351 98 11/12/2026
11.0.350 91 11/12/2026
11.0.349 93 11/11/2026
11.0.347 95 11/11/2026
11.0.345 89 11/11/2026
11.0.344 91 11/11/2026
11.0.343 85 11/11/2026
11.0.342 83 11/11/2026
11.0.340 105 11/10/2026
11.0.339 124 11/7/2026
11.0.338 98 11/4/2026
11.0.337 87 11/4/2026
11.0.336 81 11/3/2026
11.0.335 79 11/3/2026
11.0.334 75 11/3/2026
11.0.333 73 11/3/2026
11.0.330 75 11/3/2026
11.0.329 69 11/3/2026
11.0.327 79 11/3/2026
Loading failed

Updated Soenneker.TestHosts.Unit to 11.0.232