简体   繁体   English

木偶戏被卡在弹出窗口上

[英]puppeteer gets stuck on popup window

I encountered a strange website that puppeteer cannot get by. 我遇到了一个木偶无法访问的奇怪网站。 Here is the link. 链接在这里。 https://www.aliveandcooking.com.au/index.php/recipe/baked_blt_club_sandwich https://www.aliveandcooking.com.au/index.php/recipe/baked_blt_club_sandwich

When I visit the site I get a popup, saying that I need to update my Macromedia Flash. 当我访问该网站时,会弹出一个窗口,说我需要更新Macromedia Flash。 (That probably indicates that it's an old site.) (这可能表明它是一个旧站点。) 在此处输入图片说明

I tried using 我尝试使用

page.on("dialog", ...);

That didn't work. 那没用。 Any idea how can I dismiss this dialog with puppeteer? 知道如何与人偶一起关闭此对话框吗?

The reason I did not detect the dialog popup is because I put the page.on eventListener after the await page.goto . 我没有检测到对话框弹出窗口的原因是因为我将await page.goto 。放在page.on wait page.goto之后。 With the correct order the code worked perfectly: 按照正确的顺序,代码可以完美运行:

const page = await browser.newPage();
page.setViewport({
    width: 1024,
    height: 768
});
page.on('dialog', async dialog => {
    console.log(dialog.message());
    await dialog.dismiss();
});
await page.goto(link, {
    timeout: 20000,
    waitUntil: [ 'load' ]
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM