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.

Unable to get all iframes in the page

See original GitHub issue

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

const puppeteer = require("puppeteer");
const url = `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe`;

(async () => {
	const browser = await puppeteer.launch({
		headless: false,
		defaultViewport: null,
	});
	const page = await browser.newPage();
	await page.goto(url);
	await new Promise((resolve) => setTimeout(resolve, 5000));
	const frames = await page.frames();
	console.log("frames", frames.length);
})();

  1. Run the code
  2. Logs

What is the expected result?

  • 3 total frames. Page has two iframes in the page that you can see by using page’s devtools and running document.getElementsByTagName('iframe') Screen Shot 2020-06-08 at 2 29 56 PM

What happens instead?

  • We get just one frame which is the top frame/page.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lionel126commented, Sep 17, 2020

have a look thru #5123 there’s a resolution . I tried and it works

0reactions
stale[bot]commented, Jul 24, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get all iframe elements? - Stack Overflow
First, <script> tags should go either in the <head> or the <body> but not in between! I would change your naming scheme slightly...
Read more >
How To Get an Element in an iframe - W3Schools
Click the button to hide the first H1 element in the iframe (another document). Hide H1 Element. Get Element in Iframe. Get the...
Read more >
How to handle iFrame in Selenium - BrowserStack
It is possible to identify the iframes on a web page in two ways: Right-click on the specific element and check all the...
Read more >
The ultimate guide to iframes - LogRocket Blog
Not a fan of iframes? This post provides an overview of the tag's best features, shows you how to use them, and how...
Read more >
Scraping iframes with Puppeteer - Help · Apify
How to get information from inside iframes using Puppeteer. ... For all references about page and frame objects (and Puppeteer generally), you should...
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