Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Use page.mainFrame().childFrames() to get the main frame’s direct child frames. To include nested descendants, recursively visit each frame’s childFrames(); to get a flat list of every frame currently attached to the page, use page.frames().
Choose the method that matches the frame scope
| Need | Method | What it returns |
|---|---|---|
| Direct children of the main frame | page.mainFrame().childFrames() |
Immediate child frames only |
| Descendants at any nesting depth | Recursively call childFrames() |
All descendants, excluding the starting frame |
| Every currently attached frame | page.frames() |
A flat array that includes the main frame |
These methods are documented in the Frame.childFrames(), Frame, and Page references.
As an Amazon Associate I earn from qualifying purchases.
Get the main frame’s direct child frames
Once you have a Puppeteer Page, call mainFrame() and then childFrames():
const childFrames = page.mainFrame().childFrames();
for (const frame of childFrames) {
console.log(frame.url());
}
This is a one-level lookup. If a child frame contains its own iframe, that nested frame is not included in this array.
#1 Best Overall
Find nested child frames recursively
Walk each child’s descendants to collect every nested frame below the main frame:
function collectFrames(frame) {
return frame.childFrames().flatMap(child => [child, ...collectFrames(child)]);
}
const childFrames = collectFrames(page.mainFrame());
for (const frame of childFrames) {
console.log(frame.url());
}
The result includes all descendants and excludes the main frame itself. For a recursive traversal that also processes frames as it visits them, use:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
function visitChildFrames(frame, visit) {
for (const child of frame.childFrames()) {
visit(child);
visitChildFrames(child, visit);
}
}
visitChildFrames(page.mainFrame(), frame => {
console.log(frame.url());
});
Puppeteer’s official Frame documentation demonstrates traversing the frame tree using childFrames().
Recommended Free Tools
List all frames attached to the page
If you do not need to distinguish parent and child relationships, use page.frames():
Rank #3
const frames = page.frames();
for (const frame of frames) {
console.log(frame.url());
}
This is a flat list of all frames currently attached to the page, including the main frame. Filter or inspect the list when you need a page-wide search rather than traversal from a particular parent.
Identify a frame by its iframe element
If you know an iframe’s name attribute, the Frame reference documents finding the associated frame by inspecting each frame’s element:
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
const targetFrame = await (async () => {
for (const frame of page.frames()) {
const element = await frame.frameElement();
const name = await element.evaluate(el => el.getAttribute('name'));
if (name === 'checkout') {
return frame;
}
}
})();
if (targetFrame) {
console.log('Found:', targetFrame.url());
}
Use the returned Frame object for work inside that frame. A frame-scoped query, for example, is await targetFrame.$eval('h1', el => el.textContent). The frame element identifies the iframe in its parent document; the frame object is the context for querying or evaluating in the frame’s own document.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Use the parent relationship when traversing upward
Call frame.parentFrame() to get a frame’s parent. It returns null for the main frame and for a detached frame. See the official Frame.parentFrame() reference.
Best Value
Account for frame lifecycle changes
A page’s frame tree changes as frames attach, navigate, or detach. If the target may be created or removed during page activity, collect or refresh frame references after the relevant change rather than assuming an earlier list is current. Puppeteer documents these lifecycle events in its Frame reference.
When reading or evaluating page content, use the specific frame object. Puppeteer notes: “When JavaScript is executed in a frame, the JavaScript does not affect frames inside the ambient frame the JavaScript executes in.” Evaluating in the main frame does not automatically query nested frame documents.
Or skip the browser setup
If your goal is a screenshot rather than frame inspection, ScreenshotNeo can return one with a GET request, without setting up Puppeteer:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. It accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides screenshot tools for AI agents and other MCP clients. The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.
Sign up for 1,000 free screenshots a month, with no card.
Quick Recap
Troubleshoot common frame lookup problems
- A nested frame is missing:
childFrames()returns immediate children only. Recurse through each child or usepage.frames()for a flat page-wide list. - The frame is not in the list: It may not have attached yet, or it may have detached. Refresh the list after the page’s frame lifecycle changes.
- A query does not find content inside an iframe: Run the query against the frame’s
Frameobject, not the main frame’s document. Use a frame-scoped method such asframe.$eval(). parentFrame()returnsnull: That is expected for the main frame; the method also returnsnullfor a detached frame.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




