@@ -47,6 +47,32 @@ public async Task ShouldSupportToBeChecked()
4747 StringAssert . Contains ( "LocatorAssertions.ToBeCheckedAsync with timeout 300ms" , exception . Message ) ;
4848 }
4949
50+ [ PlaywrightTest ( "tests/page/expect-boolean.spec.ts" , "with indeterminate:true" ) ]
51+ public async Task WithIndeterminateTrue ( )
52+ {
53+ await Page . SetContentAsync ( "<input type=checkbox></input>" ) ;
54+ await Page . Locator ( "input" ) . EvaluateAsync ( "e => e.indeterminate = true" ) ;
55+ await Expect ( Page . Locator ( "input" ) ) . ToBeCheckedAsync ( new ( ) { Indeterminate = true } ) ;
56+ }
57+
58+ [ PlaywrightTest ( "tests/page/expect-boolean.spec.ts" , "with indeterminate:true and checked" ) ]
59+ public async Task WithIndeterminateTrueAndChecked ( )
60+ {
61+ await Page . SetContentAsync ( "<input type=checkbox></input>" ) ;
62+ await Page . Locator ( "input" ) . EvaluateAsync ( "e => e.indeterminate = true" ) ;
63+ var exception = await PlaywrightAssert . ThrowsAsync < PlaywrightException > ( ( ) => Expect ( Page . Locator ( "input" ) ) . ToBeCheckedAsync ( new ( ) { Indeterminate = true , Checked = false } ) ) ;
64+ StringAssert . Contains ( "Can't assert indeterminate and checked at the same time" , exception . Message ) ;
65+ }
66+
67+ [ PlaywrightTest ( "tests/page/expect-boolean.spec.ts" , "fail with indeterminate: true" ) ]
68+ public async Task FailWithIndeterminateTrue ( )
69+ {
70+ await Page . SetContentAsync ( "<input type=checkbox></input>" ) ;
71+ var locator = Page . Locator ( "input" ) ;
72+ var exception = await PlaywrightAssert . ThrowsAsync < PlaywrightException > ( ( ) => Expect ( locator ) . ToBeCheckedAsync ( new ( ) { Indeterminate = true , Timeout = 1000 } ) ) ;
73+ StringAssert . Contains ( "LocatorAssertions.ToBeCheckedAsync with timeout 1000ms" , exception . Message ) ;
74+ }
75+
5076 [ PlaywrightTest ( "playwright-test/playwright.expect.spec.ts" , "should be able to set default timeout" ) ]
5177 public async Task ShouldBeAbleToSetDefaultTimeout ( )
5278 {
@@ -720,6 +746,43 @@ public async Task ToHaveAccessibleDescription()
720746 await Expect ( Page . Locator ( "div" ) ) . ToHaveAccessibleDescriptionAsync ( new Regex ( "hello" ) , new ( ) { IgnoreCase = true } ) ;
721747 }
722748
749+ [ PlaywrightTest ( "page/expect-misc.spec.ts" , "toHaveAccessibleErrorMessage" ) ]
750+ public async Task ToHaveAccessibleErrorMessage ( )
751+ {
752+ await Page . SetContentAsync ( @"
753+ <form>
754+ <input role=""textbox"" aria-invalid=""true"" aria-errormessage=""error-message"" />
755+ <div id=""error-message"">Hello</div>
756+ <div id=""irrelevant-error"">This should not be considered.</div>
757+ </form>" ) ;
758+ var locator = Page . Locator ( "input[role=\" textbox\" ]" ) ;
759+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( "Hello" ) ;
760+ await Expect ( locator ) . Not . ToHaveAccessibleErrorMessageAsync ( "hello" ) ;
761+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( "hello" , new ( ) { IgnoreCase = true } ) ;
762+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( new Regex ( @"ell\w" ) ) ;
763+ await Expect ( locator ) . Not . ToHaveAccessibleErrorMessageAsync ( new Regex ( "hello" ) ) ;
764+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( new Regex ( "hello" ) , new ( ) { IgnoreCase = true } ) ;
765+ await Expect ( locator ) . Not . ToHaveAccessibleErrorMessageAsync ( "This should not be considered." ) ;
766+ }
767+
768+
769+ [ PlaywrightTest ( "page/expect-misc.spec.ts" , "toHaveAccessibleErrorMessage should handle multiple aria-errormessage reference" ) ]
770+ public async Task ToHaveAccessibleErrorMessageShouldHandleMultipleAriaErrormessageReference ( )
771+ {
772+ await Page . SetContentAsync ( @"
773+ <form>
774+ <input role=""textbox"" aria-invalid=""true"" aria-errormessage=""error1 error2"" />
775+ <div id=""error1"">First error message.</div>
776+ <div id=""error2"">Second error message.</div>
777+ <div id=""irrelevant-error"">This should not be considered.</div>
778+ </form>" ) ;
779+ var locator = Page . Locator ( "input[role=\" textbox\" ]" ) ;
780+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( "First error message. Second error message." ) ;
781+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( new Regex ( "first error message." , RegexOptions . IgnoreCase ) ) ;
782+ await Expect ( locator ) . ToHaveAccessibleErrorMessageAsync ( new Regex ( "second error message." , RegexOptions . IgnoreCase ) ) ;
783+ await Expect ( locator ) . Not . ToHaveAccessibleErrorMessageAsync ( new Regex ( "This should not be considered." , RegexOptions . IgnoreCase ) ) ;
784+ }
785+
723786 [ PlaywrightTest ( "page/expect-misc.spec.ts" , "toHaveRole" ) ]
724787 public async Task ToHaveRole ( )
725788 {
0 commit comments