Skip to content

PlaywrightAssertionException ​

Added in: v1.65

Extends: PlaywrightException

PlaywrightAssertionException is thrown when an assertion is not met, e.g. LocatorAssertions.ToBeVisibleAsync() times out waiting for the element. It inherits from PlaywrightException, so catch (PlaywrightException) blocks catch it as well.

csharp
try
{
    await Expect(page.GetByRole(AriaRole.Button)).ToBeVisibleAsync();
}
catch (PlaywrightAssertionException e)
{
    Console.WriteLine($"Assertion failed: {e.Message}");
}

Released under the Apache 2.0 License.