New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iframe present in the DOM is not listed in page.frames() #1140
Comments
I have the same problem 1+ |
Can you guys please share the exact script and URL? |
It is the exact script and it works on any page that includes iframes. |
It is not runnable. To simplify the life of project maintainers, please provide runnable scripts that include URLs so that we can easily reproduce your issue locally. |
Aren't you paid to do this? Others are contributing their time. The above is more than enough to reproduce the issue that multiple people reported. Just closing this issue shows your complete indifference to this project. |
I have the same problem too.. |
This script does not repro the issue described in the OP: const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://jsbin.com/');
await page.waitForSelector('iframe[src*=runner]');
const frames = page.frames();
const runnerFrame = frames.find(frame => frame.url().includes('runner'));
console.log(runnerFrame.url()); // runnerFrame is in page.frames()
await browser.close();
})(); This is why we've asked for a URL and full example to repro the issue. If someone can provide those details, that would be marvelous. |
@ebidel I've put a demo repo together that illustrates the problem: https://github.com/achingbrain/puppeteer-frames Just I think it might be something to do with iframes loading remote content because if you comment out this line everything works as expected. |
@achingbrain thanks, that's due to the out-of-process iframes. I filed a separate issue: #2548 |
I ran into the same issue. I found a workaround/hack that might help folks here: /**
* Waits until the iframe is attached and then returns it to the caller
*
* @access public
* @param {object} page - The Puppeteer page API object
* @param {string} nameOrId - The name or id of the target iframe
* @returns {object} The Puppeteer iframe element
*/
async function iframeAttached(page, nameOrId) {
return new Promise(async resolve => {
const pollingInterval = 1000;
const poll = setInterval(async function waitForIFrameToLoad() {
const iFrame = page.frames().find(frame => frame.name() === nameOrId);
if (iFrame) {
clearInterval(poll);
resolve(iFrame);
}
}, pollingInterval);
});
} Now, you can get your iframes like this: const iframe = await iframeAttached(page, 'YOUR_IFRAME_NAME_OR_ID');
// You can now use the iframe
iframe.doSomething(...); |
This worked for me: #5123 (comment) |
Consider the following scenario:
The selector
iframe[src*=tnspayments]
is resolved, but at this timepage.frames()
does not know of the frame.This feels like a browser bug.
Adding an arbitrary wait time solves the issues.
I suppose a thorough implementation could wait for
frameattached
.Bringing this up in case it is not a desired behaviour.
The text was updated successfully, but these errors were encountered: