puppeteer: [Bug]: Cannot get response from iframe

Bug expectation

Same as issue: https://github.com/puppeteer/puppeteer/issues/8473, always TimeoutError got

TimeoutError: Timeout exceeded while waiting for event at Timeout.eval (webpack:///./node_modules/puppeteer-core/lib/cjs/puppeteer/common/util.js?:168:28) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)

6GL4P7)XC96DVHE 6_PQ~{B

Bug behavior

  • Flaky
  • PDF

Minimal, reproducible example

const page = await browser.newPage();
        try {
            await page.goto("http://www.10010.com/net5/091/###")
            console.log('start check:' + mobile)
            await page.waitForTimeout(1000)

            // const frameXPath = "/html/body/div/div[4]/div/div[2]/iframe";
            // const frame = await page.waitForXPath(frameXPath);
            // console.log('frame.content',await frame.content())
            // const frames = await page.frames()
            // console.log('frames.length='+frames.length)

            // const div = page.waitForSelector('#aria5iipudb7pq8 > div.width100.banner_div1.ariaskiptheme.skipAutoFix > div > div.banner_right_div.ariaskiptheme.skipAutoFix')
            console.log('result=', Array.from(await page.frames()).map(i => i.url()))

            const frameUrl = 'https://upay.10010.com/npfweb/npfcellweb/phone_speedy.html'
            let frame = await (await page.frames()).find(f => f.url() === frameUrl)
            if (!frame) {
                await page.waitForTimeout(1000)
                frame = await (await page.frames()).find(f => f.url() === frameUrl)
            }
            if (!frame) {
                await page.waitForTimeout(1000)
                frame = await (await page.frames()).find(f => f.url() === frameUrl)
            }
            if (!frame) {
                await page.waitForTimeout(1000)
                frame = await (await page.frames()).find(f => f.url() === frameUrl)
            }
            console.log('frame', !!frame)
            if (!frame) {
                throw 'Target not found'
            }
            const inputSelector = "#number"
            const input = await frame.waitForSelector(inputSelector)
            console.log('input=', input)
            await input.focus()
            await input.click({clickCount: 3})
            await input.type(mobile)
            console.log('inputed')
            /**
             *
             * @type {HTTPResponse}
             */
            console.log('waiting for response')
            let response = await page.waitForResponse(response => /\/npfweb\/getArea\/init/i.test(response.url()))
            if (response.ok()) {
                console.log('response got', response)
                const data = await response.text();
                if (!data.endsWith('success')) {
                    throw new Error(response.status() + " " + data)
                }
            } else {
                throw new Error(response.status() + " " + response.statusText())
            }
            response = await page.waitForResponse(response => /\/npfweb\/NpfWeb\/customInfo\/cellInfoQuery/i.test(response.url()))
            if (response.ok()) {
                const data = await response.text();
                console.log('response', data)
                if (data.endsWith('success')) {
                    return data;
                }
                throw new Error(response.status() + " " + data)
            } else {
                throw new Error(response.status() + " " + response.statusText())
            }
        } finally {
            // page.close()
        }

Error string

TimeoutError: Timeout exceeded while waiting for event

Puppeteer configuration

No response

Puppeteer version

19.4.1

Node version

v16.18.1

Package manager

yarn

Package manager version

1.22.19

Operating system

Windows

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23

Most upvoted comments

headless does not support OOPIFs by default