[英]How to confirm alert popup with puppeteer
I'm clicking on a link that contains a confirm dialog but not being able to dismiss.我正在单击包含确认对话框但无法关闭的链接。
I tried to press "Enter" and use puppeteer's method to dismiss & accept the dialog but nothing happened.我尝试按“Enter”并使用 puppeteer 的方法关闭并接受对话框,但什么也没发生。
The link:链接:
<a onclick="return confirm('Yes?');" id="link" href="google.com">
I tried:我试过:
page.on('dialog', async dialog => {
console.log('here'); //does not pass
await dialog.accept();
//await dialog.dismiss();
});
and和
await page.keyboard.press('Enter');
await page.keyboard.press(String.fromCharCode(13));
Make sure you start listening to the dialog
event before clicking the link.确保在单击链接之前开始收听
dialog
事件。 Something like this:像这样的东西:
page.on('dialog', async dialog => {
console.log('here');
await dialog.accept();
});
await page.click('a');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.