@@ -219,7 +219,7 @@ function makeContext(onClose?: (context: BrowserContext) => void, initialUrl = "
219219 interactiveElements : [ ] ,
220220 } ) ) ,
221221 ariaSnapshot : vi . fn ( async ( ) => '- button "delete" [ref=e1]' ) ,
222- locator : vi . fn ( ( ) => {
222+ locator : vi . fn ( ( ) : unknown => {
223223 throw new Error ( "Unexpected locator action" ) ;
224224 } ) ,
225225 isClosed : ( ) => closed ,
@@ -994,6 +994,40 @@ it.live(
994994 ) . pipe ( Effect . provide ( layer ) ) ,
995995) ;
996996
997+ it . live (
998+ "reports a valid CSS selector that matches several elements as ambiguous, not invalid" ,
999+ ( ) =>
1000+ Effect . scoped (
1001+ Effect . gen ( function * ( ) {
1002+ const { broker, tabId } = yield * ready ;
1003+ const strict = new Error (
1004+ "locator.scrollIntoViewIfNeeded: Error: strict mode violation: locator('button[aria-label=\\'Permissions: Full access\\']') resolved to 2 elements:" ,
1005+ ) ;
1006+ contexts [ 0 ] ! . page . locator . mockImplementation (
1007+ ( ) =>
1008+ new Proxy (
1009+ { } ,
1010+ {
1011+ get : ( ) => async ( ) => {
1012+ throw strict ;
1013+ } ,
1014+ } ,
1015+ ) ,
1016+ ) ;
1017+ const failure = yield * broker
1018+ . invoke < void > ( {
1019+ scope,
1020+ tabId,
1021+ operation : "click" ,
1022+ input : { selector : "button[aria-label='Permissions: Full access']" , timeoutMs : 1_000 } ,
1023+ } )
1024+ . pipe ( Effect . flip ) ;
1025+ expect ( failure . message ) . not . toMatch ( / i n v a l i d s e l e c t o r / ) ;
1026+ expect ( failure . message ) . toMatch ( / 2 e l e m e n t s / ) ;
1027+ } ) ,
1028+ ) . pipe ( Effect . provide ( layer ) ) ,
1029+ ) ;
1030+
9971031it . live ( "reports a pending dialog without evaluating the page and resolves it explicitly" , ( ) =>
9981032 Effect . scoped (
9991033 Effect . gen ( function * ( ) {
0 commit comments