I am having an issue retrieving an IFrame within an IFrame I am not exactly sure how to get the result that I am looking for, I am able to retrieve the Parent IFrame just fine, however when trying to choose the child it does not find the selector of the click method. How would I go about solving this? I am quite new to Puppeteer
// Get Email
await click(contentBuilderFrame, getEmail)
await page.waitFor(200);
await click(contentBuilderFrame, '#index-entry > div > div > div.active > div > div > div.contentproperties-header > div.contentproperties-buttons > div > div > div > a');
await page.waitFor(200);
const container = await findFrame(page, "EmailAppContainer");
await page.waitFor(200);
// Will not find it
const child = await findFrame(container, "cloud/tools/SSO.aspx?legacy=1&env=default&appId=6DF293A1-4FDC-41CD-AA08-89EFC793C33C&deepLink=%2f%23%2femails");
// Timeout because cant find selector due to not finding frame
await click(child, '#sendflow-step-content')
findFrame Method:
async function findFrame(page, urlPart) {
const mainFrame = page.mainFrame();
const contentFrames = await getContentFrames(mainFrame);
let frame = null;
for (const contentFrame of contentFrames) {
if (contentFrame.url().includes(urlPart)) {
frame = contentFrame;
}
}
return frame;
}
getContentFrames:
async function getContentFrames(frame) {
const contentFrames = [];
const iframes = await frame.$$("iframe");
for (const iframe of iframes) {
const contentFrame = await iframe.contentFrame();
if (contentFrame != null) {
contentFrames.push(contentFrame);
let subContentFrames = await getContentFrames(contentFrame);
if (subContentFrames.length > 0) {
contentFrames.push(...subContentFrames);
}
}
}
//console.log(contentFrames);
return contentFrames;
}
My understanding here is that I get all the frames with the getContentFrames method - I made sure that is the case by logging the output for these, but unsure how to proceed from there on out?