English · .NET
Appearance
English · .NET
Appearance
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.
try
{
await Expect(page.GetByRole(AriaRole.Button)).ToBeVisibleAsync();
}
catch (PlaywrightAssertionException e)
{
Console.WriteLine($"Assertion failed: {e.Message}");
}