Skip to content

[Feature]: Custom assertions in .NET #3240

@ta-stott-oe

Description

@ta-stott-oe

🚀 Feature Request

A mechanism for defining custom assertions in Playwright .NET. The custom assertions would take advantage of the same retry logic (and any other good stuff) that the built-in assertions have.

This is possible in JS/TS, though I wouldn't expect .NET custom assertions to be registered in the same way.

Example

Expect(locator).ToContainNumberAsync(42)

Motivation

Currently, if you want to assert something that isn't covered by the built-in assertions, then you must resort to a method like ILocator.TextContentAsync() and then make a (non-Playwright) assertion on the result. In doing so, you no longer have this benefit:

Playwright includes async matchers that wait until the expected condition is met. Using these matchers makes tests non-flaky and resilient

Indeed, custom assertions/matchers are already supported in Node.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions