Catchy.Playwright 0.0.4

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

Catchy.Playwright

NuGet License: MIT

Microsoft.Playwright integration for Catchy — fluent browser and page assertions with async hooks for screenshots and traces on failure.

dotnet add package Catchy
dotnet add package Catchy.Playwright

Usage

using Catchy;
using Catchy.Playwright;
using static Catchy.Ambient;

public class LoginTests : CatchyTestBase  // or your framework base
{
    [Fact]
    public async Task Login_page_loads()
    {
        await using var playwright = await Playwright.CreateAsync();
        await using var browser = await playwright.Chromium.LaunchAsync();
        var page = await browser.NewPageAsync();
        await page.GotoAsync("https://example.com/login");

        await Assert.That(page).HasTitle("Login");
        await Assert.Soft.That(page).HasUrl("*/login");
        await Assert.Soft.That(page.Locator("h1")).HasText("Sign in");
    }
}

Assertion output in the Playwright trace

Catchy.Tracing.TracingExtensions adds TraceSuccess, TraceError, TraceInfo, and TraceWarning to IBrowserContext. Wire them to OnAssertion so every assertion result appears as a labelled group in the Playwright Trace Viewer:

using Catchy;
using Catchy.Tracing;

// In your [Before(Test)] / SetUp — after IBrowserContext is created:
await context.Tracing.StartAsync(new() { Screenshots = true, Snapshots = true });

var ctx = context; // capture in closure; each test has its own IBrowserContext
Ambient.Assert.Settings().OnAssertion.Add(async info =>
{
    var label = string.Join(" → ", info.Links);
    await (info.Status switch
    {
        AssertionStatus.Passed  => ctx.TraceSuccess(label),
        AssertionStatus.Failed  => ctx.TraceError($"{label}: {info.Exception?.Message}"),
        AssertionStatus.Skipped => ctx.TraceInfo($"{label} (skipped)"),
        _                       => Task.CompletedTask
    });
});

// In your [After(Test)] / TearDown:
await context.Tracing.StopAsync(new() { Path = "trace.zip" });

OnAssertion fires per-assertion at accumulation time (before any soft-failure flush), so a screenshot hook on OnSoftFailure captures the browser state at exactly the right moment.

Why not a global hook? A global [BeforeEvery(Test)] has no access to the IBrowserContext living in the test class instance — parallel tests would race on a shared reference. Capture context via closure inside the test's own [Before(Test)] method.

If you prefer an explicit asserter instead of the ambient one:

var assert = Asserter.NewStateful(cfg =>
    cfg.OnAssertion.Add(async info =>
    {
        var label = string.Join(" → ", info.Links);
        await (info.Status switch
        {
            AssertionStatus.Passed  => ctx.TraceSuccess(label),
            AssertionStatus.Failed  => ctx.TraceError($"{label}: {info.Exception?.Message}"),
            AssertionStatus.Skipped => ctx.TraceInfo($"{label} (skipped)"),
            _                       => Task.CompletedTask
        });
    }));

await assert.That(page.Locator("h1")).HasText("Dashboard");

Observability on failure

Wire OnSoftFailure to capture a screenshot automatically when a soft assertion fails:

var assert = Asserter.NewStateful(cfg =>
{
    cfg.OnSoftFailure = [async info => await page.ScreenshotAsync(
        new() { Path = $"failure-{info.Links[0]}.png" })];
});

await assert.Soft.That(page).HasTitle("Dashboard");

Pre-1.0 — API will change. Full docs · Usage guide

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
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 Catchy.Playwright:

Package Downloads
Catchy.Playwright.Visual

Visual assertion extensions for Catchy.Playwright powered by image-diff workflows.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.4 130 11/2/2026
0.0.2 132 11/2/2026
0.0.1 185 8/3/2026
0.0.0 162 7/30/2026