Tengo un problema al recuperar un IFrame dentro de un IFrame. No estoy exactamente seguro de cómo obtener el resultado que busco. Puedo recuperar el IFrame principal sin problemas, sin embargo, cuando trato de elegir el elemento secundario, no encuentra el selector del método clic. ¿Cómo haría para resolver esto? soy bastante nuevo en titiritero
// 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')Método findFrame:
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; }Mi entendimiento aquí es que obtengo todos los marcos con el método getContentFrames. Me aseguré de que ese sea el caso al registrar la salida para estos, pero ¿no estoy seguro de cómo proceder a partir de ahí?