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.

Wait for iframe navigation

See original GitHub issue

How I can wait for an iframe that triggers a post to server?

Following is not working

script1: //not working
const [response] = await Promise.all([
    page.waitForNavigation()
    page.click("#iframe_1");
]);

script2: //not working
await page.waitForSelector("#iframe_1");

I need to wait for post response but I frame does not causes a page navigation the looks like waitForSelector will not works

Could you suggest a strategy to follow?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vsemozhetbytcommented, Jan 28, 2019
  1. Are you sure that this frame is already available when you call page.frames()?
  2. If the mentioned option is inside the iframe, then you need frame.select(), not page.select() (and without extra away).

So can you try this:

await page.waitForSelector('iframe#basefrm');
const frame = page.frames().find(fr => fr.name() === 'basefrm');

const [response1] = await Promise.all([
  frame.waitForNavigation(),
  frame.select("input > button", "1")
]);
1reaction
aslushnikovcommented, Jan 28, 2019

@AlonsoK28 you can use frame.waitForNavigation to wait for navigation of a particular frame.

Note: this API is available in Puppeteer v1.9.0+.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wait for iframe to load in JavaScript - Stack Overflow
First of all, I believe you are supposed to affect the src property of iframes, not location . Second of all, hook the...
Read more >
Capturing the load event of an iFrame — A case study
The DOM emits the load event on iFrame only when all the static assets have been downloaded and all the elements in the...
Read more >
How to check a webpage is loaded inside an iframe or into the ...
An iFrame is a rectangular frame or region in the webpage to load or display another separate webpage or document inside it.
Read more >
Page: DOMContentLoaded, load, beforeunload, unload
The load event on the window object triggers when the whole page is loaded including styles, images and other resources. This event is...
Read more >
How to make Puppeteer wait for Iframe to finish loading? : r/node
I see you've already tried .waitForNavigation() , but that's more intended for times when navigation is indirectly triggered. I think using it ...
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