From cf7389051f1b55bbefdfbbd32f6272460bf63f1e Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Mon, 19 Feb 2024 14:21:37 +0100 Subject: [PATCH] Work with Puppeteer 22, fixes #119 --- src/spoof.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/spoof.ts b/src/spoof.ts index a78f054..83efc6f 100644 --- a/src/spoof.ts +++ b/src/spoof.ts @@ -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 | undefined if (iframes != null) { @@ -316,12 +316,13 @@ export const createCursor = ( let elem: ElementHandle | 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 } else { if (options?.waitForSelector !== undefined) {