1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate;
/// `Dialog` objects are dispatched by page via the [page::Event::Dialog](crate::api::page::Event::Dialog) event.
///
/// An example of using `Dialog` class:
///
/// ```js
/// const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
///
/// (async () => {
/// const browser = await chromium.launch();
/// const page = await browser.newPage();
/// page.on('dialog', async dialog => {
/// console.log(dialog.message());
/// await dialog.dismiss();
/// });
/// await page.evaluate(() => alert('1'));
/// await browser.close();
/// })();
/// ```
///
/// > NOTE: Dialogs are dismissed automatically, unless there is a [`event: Page.dialog`] listener. When listener is
/// present, it **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise the page will
/// [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and
/// actions like click will never finish.