【发布时间】:2020-12-20 17:30:26
【问题描述】:
我加载了一个包含 iframe 的页面,然后单击 iframe 中的链接,如下所示:
const elementHandle = await page.$('iframe');
const frame = await elementHandle.contentFrame();
await frame.click('a');
await page.waitFor(5000);
一切正常,puppeteer 导航到新页面。 现在我想在新页面中单击 en 元素。 但是我没有找到新页面的内容。
const content = await page.content();
给出原始页面。
const content = await frame.content();
在原始页面中给出 iframe 的原始内容。
如何参考新加载的页面?
【问题讨论】:
标签: javascript node.js iframe puppeteer