Can't access a frame or framesets within a frame.
See original GitHub issue- Puppeteer version: “puppeteer”: “^1.4.0”
- Platform / OS version: OSX : High Sierra
- URLs (if applicable): None
- Node.js version: node --version v10.1.0
I need help navigating to a frame within a frame (potentially any number of levels of frames could be nested).
There seem to be a lot of issues relating to accessing frames in a page and I can’t find a clear answer to what feels like a straightforward use case.
I have a frame within a frameset within a frame within the dom. I need to fill out a form within that lower level frame. But I can’t seem to access it or change the “page” context to that sub frame even though I can access the top level frame.
Ideally perhaps something like this :
const frame = page.frames()[1];
console.log(frame.frames()) // hangs pupeteer and fails?
I can’t change anything about the architecture of the pages right now, but my question is really that I want some more clarity about what pupeteer can and can’t do.
I would ideally like the ability to do what i described above. Just access the frame
object as a subsequent page
object.
Is there some documentation I’m missing because this feels straightforward. I am however working with some old technology so i’m not expecting too much information to be out there. All I’ve been able to find is workarounds on the related issues and nothing particularly clear.
Thanks in advance for any help!
Related Issues and Questions :
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
of the top of my head im not sure what the exact snippet would be to get what you want but,
frame frame2 frame3 will always be the same frame, as nothing changes inbetween right?
(await page.frames())[0] this is the mainframe (await page.frames())[1] this is the first frame of the mainframe (await page.frames())[2] this is the second frame of the mainframe (await (await page.frames()[1].childFrames())[0] would be the first frame of the first frame of the mainframe
https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-frame
@davidawad frame structure is not flattened; frames have subframes, so you should query frame’s children when you want to get them.
P.S. there’s also a
frame.name()
that you can use instead of reaching out for a privateframe['name']
.