问题
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