microsoft / microsoft/playwright-dotnet
[Feature]: Custom assertions in .NET
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3k
- Forks
- 304
- Avg merge
- 20h 47m
- Merged PRs (30d)
- 6
Description
🚀 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked Playwright JS/TS custom matcher documentation and reviewing the built-in .NET assertion behavior described in the issue. Compare that with the ILocator.TextContentAsync workaround and the ToContainNumberAsync example. Done means a defined .NET mechanism for custom assertions that preserves Playwright's retry behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100