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

waitForFrameToLoad not working as expected #50

Open
mmarsella opened this issue Aug 1, 2017 · 2 comments
Open

waitForFrameToLoad not working as expected #50

mmarsella opened this issue Aug 1, 2017 · 2 comments

Comments

@mmarsella
Copy link

mmarsella commented Aug 1, 2017

I am trying to inject an iframe into a new tab and need to wait for it to finish loading before proceeding. In the example below I am trying to use waitForFrameToLoad:

const baseURL = "about:blank";
// Open up a new tab
  let mainTab = await browser.newTab();

  //inject iframe into this tab - (iframetester creates an Iframe and injects it into the DOM
  const iframe = await mainTab.evaluate(iframeTester, "http://www.exampleURL.com"); 

  await mainTab.waitForFrameToLoad(baseURL, 5000); // Should be waiting for iframe to load for this
  

The goal is to inject an iframe and wait until it has fully loaded to take next actions. The mainTab.waitForFrameToLoad doesn't throw an error, but doesn't seem to be waiting - ideally I would want to be listening for any changes in the DOM (as well as if the src inside the iframe busts out/etc...)- Is there support for page listeners such as Page.loadEventFired as well as the other Page domain listeners? How would I be able to implement these listeners using your library?

Thanks so much.

M

@LucianoGanga
Copy link
Owner

Hello @mmarsella !

I think that this case won't work with waitForFrameToLoad, because that method uses the function above, which tries to seek the frames in the resource tree of the page:

/**
 * Get the list of frames in the loaded page
 * @return {object} - List of frames, with childFrames
 */
exports.getFrames = async function () {
  debug(`:: getFrames => Getting frames list`)
  browserIsInitialized.call(this)
  const frames = []
  const resourceTree = await this.client.Page.getResourceTree()
  frames.push(resourceTree.frameTree.frame)
  _.each(resourceTree.frameTree.childFrames, (frameObj) => {
    frames.push(frameObj.frame)
  })
  return frames
}

What I mean with this is that I'm not sure if you can dynamically add a frame and hope for the getFrames method to find it in the resourceTree.

I'll be glad to test your case if you can help me, just give me the iframeTester fn that you're using so we can create a test case for this and debug it.

Thanks!
Lucho

@mmarsella
Copy link
Author

Ok, will mock up an example and send it over when I get some free time later.

Thanks Lucho.

M

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

No branches or pull requests

2 participants