Skip to content

Instantly share code, notes, and snippets.

@supermarsx
Last active September 11, 2020 11:55
Show Gist options
  • Save supermarsx/91689a8c7637288dd03364443758eed8 to your computer and use it in GitHub Desktop.
Save supermarsx/91689a8c7637288dd03364443758eed8 to your computer and use it in GitHub Desktop.
Returns a named iframe handle with puppeteer
/*
getNamedIframe
Returns a named iframe handle with puppeteer
parameters
page (object) - Puppeteer page object
iframeName (string) - iframe name
*/
async function getNamedIframe(page, iframeName) {
iframeName = iframeName || 'main';
// Identify frame
console.log(`Getting a named iframe with name "${iframeName}" > (frame)`);
return await page.frames().find(f => f.name() === iframeName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment