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.

waitForSelector not working for iframe, unable to find element in iframe

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.4.0
  • Platform / OS version: macOS X 10.13.4
  • URLs (if applicable): https://getvase.com
  • Node.js version: v8.11.1

What steps will reproduce the problem?

Please include code that reproduces the issue.

describe('Main page', () => {
  test(
    'Initiate account kit signup',
    async () => {
      await page.goto('http://localhost:3000/')

      // Click on phoneNumberView and enter number
      await page.waitForSelector('.App-phone-number-input')
      await page.click('input[type=tel]')
      await page.type('input[type=tel]', myPhoneNumber)
      await page.click('button[class=App-phone-go-button]')

      // Wait for account kit iframe to load
      await page.waitForSelector('iframe[src*=accountkit]')
      await page.waitFor(3000)
      const frame = await page
        .frames()
        .find(f => f.url().includes('accountkit'))
      await frame.waitForSelector('button[class=_5xrj]')
      const button = await frame.$('button[class=_5xrj]')
      await button.click()
    },
    1600000
  )
})
  1. Automated testing with Jest
  2. Input number then press submit
  3. Wait for account kit iframe unable to wait, temporary workaround of waitFor()
  4. Press account kit iframe next button unable to find the button

What is the expected result? Able to wait the iframe without page.waitFor() and press the next button

What happens instead? Unable to wait for the iframe, need to use waitFor() and unable to find the button

Tried the solution https://github.com/GoogleChrome/puppeteer/issues/1361 but not working.

Need help sincerely 😢

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

16reactions
aslushnikovcommented, May 31, 2018

@joevo2 can you try running browser with the following flag:

const browser = await puppeteer.launch({                                                                                                                                                                                                                                                            
  args: ['--disable-features=site-per-process'],                                                                                                                                                                                                                                                    
  headless: false                                                                                                                                                                                                                                                                                   
}) ;

if it helps then this is due to #2548.

13reactions
mayankchincholkarcommented, Mar 20, 2019

Thanks @aslushnikov and @joevo2 you guys saved my day. Awesome stuff 👍

However, I am still unable to perform certain operations. Like await frame.$eval(‘#selector’, element => element.textContent); works fine however, await frame.waitForSelector(‘#selector’,{visible: true}); times out for the same selector. Can you please help here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to select elements within an iframe element in Puppeteer
You can get the iframe using contentFrame as you are doing now, and then call $ . const browser = await puppeteer.launch({ headless:...
Read more >
puppeteer.Frame JavaScript and Node.js code examples
Closes browser with all the pages (if any were opened). Page.evaluate. Evaluates a function in the browser context. Page.click,; Page.waitForSelector,; Page.
Read more >
Scraping iframes with Puppeteer - Help · Apify
How to get information from inside iframes using Puppeteer. ... of page objects like 'page.evaluate()', you are actually already working with frames.
Read more >
Scraping iframes with Puppeteer - Agenty
Navigate to the page using page.goto() · Find the iframe by name() or url() · Wait for selector to ensure iframe loaded using...
Read more >
Puppeteer documentation - DevDocs
There might be other frames created by iframe or frame tags. ... NOTE Extensions in Chrome / Chromium currently only work in non-headless...
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