SnowBank.Testing.Framework.Playwright 7.4.2

dotnet add package SnowBank.Testing.Framework.Playwright --version 7.4.2
                    
NuGet\Install-Package SnowBank.Testing.Framework.Playwright -Version 7.4.2
                    
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="SnowBank.Testing.Framework.Playwright" Version="7.4.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SnowBank.Testing.Framework.Playwright" Version="7.4.2" />
                    
Directory.Packages.props
<PackageReference Include="SnowBank.Testing.Framework.Playwright" />
                    
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 SnowBank.Testing.Framework.Playwright --version 7.4.2
                    
#r "nuget: SnowBank.Testing.Framework.Playwright, 7.4.2"
                    
#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 SnowBank.Testing.Framework.Playwright@7.4.2
                    
#: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=SnowBank.Testing.Framework.Playwright&version=7.4.2
                    
Install as a Cake Addin
#tool nuget:?package=SnowBank.Testing.Framework.Playwright&version=7.4.2
                    
Install as a Cake Tool

SnowBank.Testing.Framework.Playwright

A virtual web browser component for the SnowBank distributed-test framework, backed by a real Playwright-driven Chromium.

Concept

The SnowBank distributed-test framework (SnowBank.Testing.Framework) lets you spin up several simulated hosts (web hosts, agents, services) on an in-memory virtual network inside a single test, with all of their traffic routed in-process, without real sockets or TCP ports.

This package adds a browser to that network: a real Chromium instance, driven through Playwright, whose HTTP and WebSocket traffic is routed onto the same virtual network. So a genuine browser renders and drives the pages served by your simulated web hosts, end-to-end, with no external server to start and no free port to allocate.

The browser is exposed as an ordinary Playwright IPage (via browser.Page), so everything you already know from Playwright works unchanged (GotoAsync, locators, ClickAsync, ContentAsync, screenshots).

Chromium is downloaded automatically the first time a test runs.

How to use

Add the package to your test project (it pulls in Microsoft.Playwright):

dotnet add package SnowBank.Testing.Framework.Playwright

Then, in a DistributedTest, put a web host and a browser on the same virtual LAN and drive the browser with the standard Playwright API:

public class MyBrowserFacts : DistributedTest
{
    [Test]
    public async Task Browser_Renders_A_Page_Served_On_The_Virtual_Network()
    {
        var context = await MakeItSo(env => env.AddSimpleLan(lan =>
        {
            // a simulated web host serving a page
            lan.WithMinimalWebHost("WEB", host =>
            {
                host.ConfigureApplication(app =>
                    app.MapGet("/", () => Results.Content("<html><body>hello</body></html>", "text/html")));
            });

            // a real Chromium on the same virtual network
            lan.WithPlaywrightBrowser("BROWSER");
        }));

        var web = context.GetWebHost("WEB");
        var browser = context.GetPlaywrightBrowser("BROWSER");

        // `browser.Page` is a standard Playwright IPage; the request is routed over the virtual network
        var response = await browser.Page.GotoAsync(web.GetUri("/").ToString(), new() { WaitUntil = WaitUntilState.Load });
        Assert.That(response!.Ok, Is.True);

        var body = await browser.Page.ContentAsync();
        Assert.That(body, Does.Contain("hello"));
    }
}

Options

WithPlaywrightBrowser(id, configure) exposes a few options through its builder:

  • WithVirtualClock(): run the page under a virtual clock, advanced explicitly by the test, for deterministic time-dependent UI.
  • WithRemoteDebugging(port): expose the browser's Chrome DevTools Protocol (CDP) endpoint on a real loopback port, so an external controller (an inspector, or an agent-driven Playwright client) can attach with connectOverCDP and co-drive the same browser while the component keeps owning all virtual routing.
  • ConfigureServices / ConfigureApplication and OnStartup / OnShutdown: the usual host-configuration and lifecycle hooks.

The PlaywrightPageExtensions helpers add convenience methods on top of the raw IPage, for example waiting until a page has settled.

Note: these tests drive a real Chromium, so they are heavier than pure unit tests and are usually marked [Explicit]. Chromium is installed automatically on first run.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.4.2 52 7/13/2026