Skip to content

Commit

Permalink
Work with Puppeteer 22, fixes #119
Browse files Browse the repository at this point in the history
  • Loading branch information
Niek committed Feb 19, 2024
1 parent 9a43cab commit cf73890
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/spoof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const getElementBox = async (
const elementFrame = await element.contentFrame()
const iframes =
elementFrame != null
? await elementFrame.parentFrame()?.$x('//iframe')
? await elementFrame.parentFrame()?.$$('xpath/.//iframe')
: null
let frame: ElementHandle<Node> | undefined
if (iframes != null) {
Expand Down Expand Up @@ -316,12 +316,13 @@ export const createCursor = (
let elem: ElementHandle<Element> | null = null
if (typeof selector === 'string') {
if (selector.startsWith('//') || selector.startsWith('(//')) {
selector = `xpath/.${selector}`
if (options?.waitForSelector !== undefined) {
await page.waitForXPath(selector, {
await page.waitForSelector(selector, {
timeout: options.waitForSelector
})
}
const [handle] = await page.$x(selector)
const [handle] = await page.$$(selector)
elem = handle.asElement() as ElementHandle<Element>
} else {
if (options?.waitForSelector !== undefined) {
Expand Down

0 comments on commit cf73890

Please sign in to comment.