4

I am trying the contents of iFrame and the iFrame doesn't have an src or URL. It has id element. Below is code I am trying to use . Is there anything I am missing here ? Content is empty

await page.goto("https://sites.google.com/view/pinnednote/home", { waitUntil: 'load', timeout: 30000 });
const myFrames = await page.frames();
console.log("Parent IFrame = "+myFrames.length)

for ( x of myFrames) { // Getting all iFrames
  try {
    const frameElement = await x.frameElement();
    const contentFrame = await frameElement.contentFrame();
    console.log(await contentFrame.content());
  } catch(error){
    console.log(error)
  }
  childs = await x.childFrames();
  console.log("Child IFrame = "+childs.length)
  for ( y of childs) { 
    const frameElement = await y.frameElement();
    const contentFrame = await frameElement.contentFrame();
    console.log(await contentFrame.content());
  }
}

1 Answer 1

3

Try this:

await page.goto("https://sites.google.com/view/pinnednote/home", { waitUntil: 'load', timeout: 30000 });
const myFrames = await page.frames();
console.log("Parent IFrame = "+myFrames.length)

for ( x of myFrames) { // Getting all iFrames
  try {
    const frameContent = await x.content();
    console.log(frameContent)
  } catch(error){
    console.log(error)
  }
}

You already have the frames in your myFrames array. When you are making the loop you only need to take the content.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.