question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't retrieve IFrame in {headless: false} mode

See original GitHub issue

Steps to reproduce

  1. Take prepared repository https://github.com/pahan35/puppeteer-stripe-iframe-detection-bug
  2. Install packages npm i
  3. Run npm start

Tell us about your environment:

What steps will reproduce the problem?

const puppeteer = require('puppeteer')
const {Events} = require('puppeteer/lib/Events')

;(async () => {
  const browser = await puppeteer.launch({
    headless: false,
  })

  const page = await browser.newPage()

  const waitForFrame = async name => {
    const frames = new Set()
    return new Promise((resolve, reject) => {
      const wait = setTimeout(() => {
        reject(
          Error(
            `Timeout while waiting for frame "${name}", have: ${JSON.stringify(
              [...frames],
            )}`,
          ),
        )
      }, 10000)

      function checkFrame() {
        const frame = page.frames().find(f => {
          const fname = f.name()
          frames.add(fname)
          return fname.includes(name)
        })
        if (frame) {
          clearTimeout(wait)
          resolve(frame)
        } else {
          page.once(Events.Page.FrameNavigated, checkFrame)
        }
      }

      checkFrame()
    })
  }

  await page.goto('https://stripe-payments-demo.appspot.com')

  try {
    const stripeFrame = await waitForFrame('privateStripeFrame')
    await stripeFrame.waitFor('body')
    console.log('Body found successfully')
  } catch (e) {
    console.error(e)
  }
  process.exit()
})()
  1. Just run code above

What is the expected result? I expect to see Body found successfully from script, as it works in headless: true mode

What happens instead? Puppeteer fails on retrieving iframe

Extra info is described in README.MD of the linked repo

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tshmitcommented, Sep 28, 2019
0reactions
OrKoNcommented, Sep 5, 2022

That should work in the latest version, I believe. Please open a new issue if it still reproduces.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Iframe is not loading properly in Headless mode of ...
This is because of the React iframe not supported in Electron browser. Set the chrome browser using command --browser chrome in package.json ...
Read more >
Object iframe is not present on Headless Chrome, please help
I think your best bet is to create a new test case that gets executed exclusively in headless mode. You'd have to re-base...
Read more >
Issue 2198: ChromeDriver 2.34 doesn't wait until iframe ...
trying to click on any element in the Iframe will fail. trying to wait for any element will fail. trying to get the...
Read more >
How To Handle iFrames In Cypress | Cypress Advanced Tutorial
... How To Run Cypress Tests In Headless Mode : https://bit.ly/3AB03e6 *Useful Blogs & Docs* ♢ Getting Started With Cypress ...
Read more >
Getting to Know Puppeteer Using Practical Examples
Because of the fact that the browser is launched in headless mode by default, ... const browser = await puppeteer.launch({ headless: false, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found