You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Subtype PlaywrightException in the case of failing assertions #2940
I am following the guidance of `Expect'- first assertions and migrating away from NUnit assertions in the process. However, it was useful to me to know when a test failed because of an assertion exception, or when the test was was improperly crafted.
Hi, the Playwright bot investigated this on my behalf.
A distinct assertion exception is not currently available. Failed Expect calls still throw PlaywrightException, including through the NUnit base classes. Custom expect messages add context but do not provide a separate exception type.
Should the proposed subtype identify only unmet expectations, leaving invalid selectors and other execution failures as ordinary errors, or every failure from Expect? Invalid selectors and strict mode violations currently use the same assertion failure formatting, so changing the exception type alone would still classify some improperly crafted tests as assertion failures.
Evidence and acceptance criteria
Inspected current main at 9eac4c8456fdf60f01df5e0dc58f4ebe64239781. This was a source and documentation review. No builds or tests were run.
Locator and page assertions construct PlaywrightException in
Once the boundary is agreed, an acceptance check can extend existing ShouldSupportToBeChecked with an exact subtype assertion while retaining its message checks and base exception compatibility. Existing invalid selector and strict mode cases should pin the chosen boundary, and the existing response failure case should cover its separate throw site. These are proposed checks, not executed results.
The issue remains marked P3-collecting-feedback, with no comments, linked PR, or recorded approval of the API design in its timeline.
Sounds like the bot needs to learn that a feature request asks for something that is, by definition, not currently available 😅
The latter half of the response implies some technical difficulties, but they seem surmountable to me. I don't think there was ever a question of technical feasibility here, only one of design.
Activity
dcrousso commentedon Oct 21, 2026
Hi, the Playwright bot investigated this on my behalf.
A distinct assertion exception is not currently available. Failed
Expectcalls still throwPlaywrightException, including through the NUnit base classes. Custom expect messages add context but do not provide a separate exception type.Should the proposed subtype identify only unmet expectations, leaving invalid selectors and other execution failures as ordinary errors, or every failure from
Expect? Invalid selectors and strict mode violations currently use the same assertion failure formatting, so changing the exception type alone would still classify some improperly crafted tests as assertion failures.Evidence and acceptance criteria
9eac4c8456fdf60f01df5e0dc58f4ebe64239781. This was a source and documentation review. No builds or tests were run.PlaywrightExceptioninplaywright-dotnet/src/Playwright/Core/AssertionsBase.cs
Lines 82 to 98 in 9eac4c8
playwright-dotnet/src/Playwright/Core/APIResponseAssertions.cs
Lines 48 to 83 in 9eac4c8
StrictModeViolationErrorFormatandInvalidSelectorErrorFormatcases demonstrate the classification boundary that needs a decision:playwright-dotnet/src/Playwright.Tests/Assertions/LocatorAssertionsTests.cs
Lines 841 to 858 in 9eac4c8
playwright-dotnet/src/Playwright.NUnit/PlaywrightTest.cs
Lines 49 to 61 in 9eac4c8
PlaywrightExceptionwould not itself be NUnit'sAssertionException: https://docs.nunit.org/api/NUnit.Framework.AssertionException.html.Microsoft.Playwright.PlaywrightException: https://playwright.dev/dotnet/docs/test-assertions#custom-expect-message. The merged custom message change did not add a subtype: feat(assertions): support custom expect message #3309.ShouldSupportToBeCheckedwith an exact subtype assertion while retaining its message checks and base exception compatibility. Existing invalid selector and strict mode cases should pin the chosen boundary, and the existing response failure case should cover its separate throw site. These are proposed checks, not executed results.The issue remains marked
P3-collecting-feedback, with no comments, linked PR, or recorded approval of the API design in its timeline.RenderMichael commentedon Oct 21, 2026
Sounds like the bot needs to learn that a feature request asks for something that is, by definition, not currently available 😅
The latter half of the response implies some technical difficulties, but they seem surmountable to me. I don't think there was ever a question of technical feasibility here, only one of design.
github-actions commentedon Nov 2, 2026
Hi, I'm the Playwright bot. I started to triage this issue on Linux: agent run
github-actions commentedon Nov 4, 2026
Hi, I'm the Playwright bot. I started to triage this issue on Linux: agent run