What kind of dialog box is this? How can I interact with it using Puppeteer?

匆匆过客 提交于 2021-01-28 21:22:38

问题


I'm using puppeteer to run a Google Chrome browser(I've tried with Chromium as well), to generate a PDF and then I'm using the URL to send the PDF to some other software. I'm getting stuck at this dialog box of sorts.

I assumed it was a normal dialog box and have tried the usual method of hitting the "confirm" button. I can't seem to get it to work. I'm unable to show you the URL I am using the get this to show up, as it is sensitive.

As I mentioned, page.on() doesn't seem to catch the box.

    const newP = await browser.newPage();
    newP.on('dialog', async dialog => {
            console.log(dialog.message());
            console.log(dialog.accept());
    });
    await newP.goto(`exampleURL`);```



回答1:


This modal is not accessible from the DOM/Page. Your browser seem to redirect opening PDF files to local software on your machine. Solution: try to disconnecting or remove default program / software.

Windows: https://support.microsoft.com/en-us/help/4028161/windows-10-change-default-programs

Mac: https://www.macworld.co.uk/how-to/mac-software/change-default-apps-mac-3656510/



来源:https://stackoverflow.com/questions/60591496/what-kind-of-dialog-box-is-this-how-can-i-interact-with-it-using-puppeteer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!