website/versioned_docs/version-24.40.0/api/puppeteer.dialog.md
Dialog instances are dispatched by the Page via the dialog event.
export declare abstract class Dialog
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Dialog class.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.on('dialog', async dialog => {
console.log(dialog.message());
await dialog.dismiss();
await browser.close();
});
await page.evaluate(() => alert('1'));
Method
</th><th>Modifiers
</th><th>Description
</th></tr></thead> <tbody><tr><td><span id="accept">accept(promptText)</span>
</td><td> </td><td>A promise that resolves when the dialog has been accepted.
</td></tr> <tr><td><span id="defaultvalue">defaultValue()</span>
</td><td> </td><td>The default value of the prompt, or an empty string if the dialog is not a prompt.
<span id="dismiss">dismiss()</span>
</td><td> </td><td>A promise which will resolve once the dialog has been dismissed
</td></tr> <tr><td><span id="message">message()</span>
</td><td> </td><td>The message displayed in the dialog.
</td></tr> <tr><td><span id="type">type()</span>
</td><td> </td><td>The type of the dialog.
</td></tr> </tbody></table>