Skip to content

Commit e18a5ea

Browse files
committed
fix some issues of puppeteer helper
1 parent 40b6900 commit e18a5ea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/helper/Puppeteer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)