小编zia*_*ali的帖子

如何使用 puppeteer 确认警报弹出窗口

我正在单击包含确认对话框但无法关闭的链接。

我尝试按“Enter”并使用 puppeteer 的方法关闭并接受对话框,但什么也没发生。

链接:

<a onclick="return confirm('Yes?');" id="link" href="google.com">
Run Code Online (Sandbox Code Playgroud)

我试过:

page.on('dialog', async dialog => {
    console.log('here'); //does not pass
    await dialog.accept();
    //await dialog.dismiss();
});
Run Code Online (Sandbox Code Playgroud)

await page.keyboard.press('Enter');
await page.keyboard.press(String.fromCharCode(13));
Run Code Online (Sandbox Code Playgroud)

javascript webautomation node.js puppeteer

2
推荐指数
1
解决办法
2355
查看次数

标签 统计

javascript ×1

node.js ×1

puppeteer ×1

webautomation ×1