File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -2956,6 +2956,12 @@ async function findElement(matcher, locator) {
29562956 if ( locator . react ) return findReactElements . call ( this , locator )
29572957 locator = new Locator ( locator , 'css' )
29582958
2959+ // Check if locator is a role locator and call findByRole
2960+ if ( locator . isRole ( ) ) {
2961+ const elements = await findByRole . call ( this , matcher , locator )
2962+ return elements [ 0 ]
2963+ }
2964+
29592965 // Use proven legacy approach - Puppeteer Locator API doesn't have .first() method
29602966 if ( ! locator . isXPath ( ) ) {
29612967 const elements = await matcher . $$ ( locator . simplify ( ) )
@@ -2966,7 +2972,8 @@ async function findElement(matcher, locator) {
29662972 const elements = await matcher . $$ ( `xpath/${ locator . value } ` )
29672973 return elements [ 0 ]
29682974 }
2969- const elements = await matcher . $x ( locator . value )
2975+ // For Puppeteer 24.x+, $x method was removed - use ::-p-xpath() selector
2976+ const elements = await matcher . $$ ( `::-p-xpath(${ locator . value } )` )
29702977 return elements [ 0 ]
29712978}
29722979
You can’t perform that action at this time.
0 commit comments