Skip to content
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

docs(api.md): iframe load event #2110

Closed
wants to merge 3 commits into from
Closed

Conversation

yanivefraim
Copy link
Contributor

Fixes #1413

After playing around with frames, I figured out that execution order is:

  1. frameattached
  2. framenavigated
  3. Frame's window.onLoad

This means that the two steps are needed:

  1. Wait for Frame to be attached
  2. Wait for Frame to be loaded

I added a section in Frame docs: Waiting for a frame to be loaded, explaining this concept with the example from #1361.

I think that we might need a better built-in solution for that, something like: page.waitForFrameAttached(frameName)

WDYT?

@yanivefraim
Copy link
Contributor Author

Closing in favor of a page.waitForFrameAttached(frameName) PR

@gonzaloserrano
Copy link

Hi, tried to use page.waitForFrameAttached(1) but got TypeError: page.waitForFrameAttached is not a function. Any hints?

@yanivefraim
Copy link
Contributor Author

Hi... there is no such method. I suggested to add such a method, but did not do it, yet (not sure if this is something we want to have)

@sean-hill
Copy link

sean-hill commented May 4, 2018

@yanivefraim I'm facing an issue where this would be helpful. I have a retarded page I have to write tests against that has a DOM structure like this:

image

If I call page.childFrames() I get a list of 5 frames, and if for each of those frames I call frame.name() immediately after the page loads, they all return empty strings. However if I wait for an arbitrary amount of time until all the frames have loaded, I get back the frame names for each child. So it'd be nice to have some function to wait for a frame to be loaded.

const childFrames = await page.childFrames()
await Promise.all(childFrames.map(frame => frame.waitForLoad()))
const childFrameNames = childFrames.map(frame => frame.name)

Just a suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants