Catchy.Playwright
0.0.4
dotnet add package Catchy.Playwright --version 0.0.4
NuGet\Install-Package Catchy.Playwright -Version 0.0.4
<PackageReference Include="Catchy.Playwright" Version="0.0.4" />
<PackageVersion Include="Catchy.Playwright" Version="0.0.4" />
<PackageReference Include="Catchy.Playwright" />
paket add Catchy.Playwright --version 0.0.4
#r "nuget: Catchy.Playwright, 0.0.4"
#:package Catchy.Playwright@0.0.4
#addin nuget:?package=Catchy.Playwright&version=0.0.4
#tool nuget:?package=Catchy.Playwright&version=0.0.4
Catchy.Playwright
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 theIBrowserContextliving in the test class instance — parallel tests would race on a shared reference. Capturecontextvia 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 | Versions 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. |
-
.NETStandard 2.0
- Catchy (>= 0.0.4)
- Microsoft.Playwright (>= 1.61.0)
-
net5.0
- Catchy (>= 0.0.4)
- Microsoft.Playwright (>= 1.61.0)
-
net6.0
- Catchy (>= 0.0.4)
- Microsoft.Playwright (>= 1.61.0)
-
net7.0
- Catchy (>= 0.0.4)
- Microsoft.Playwright (>= 1.61.0)
-
net8.0
- Catchy (>= 0.0.4)
- Microsoft.Playwright (>= 1.61.0)
-
net9.0
- Catchy (>= 0.0.4)
- Microsoft.Playwright (>= 1.61.0)
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.