puppeteer/website/versioned_docs/version-22.6.3/api/puppeteer.dialog.md
release-please[bot] a63b8305ac
chore: release main (#12190)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
2024-04-05 13:11:52 +00:00

1.5 KiB

sidebar_label
Dialog

Dialog class

Dialog instances are dispatched by the Page via the dialog event.

Signature:

export declare abstract class Dialog

Remarks

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.

Example

import puppeteer from 'puppeteer';

(async () => {
  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();
  });
  page.evaluate(() => alert('1'));
})();

Methods

Method

Modifiers

Description

accept(promptText)

A promise that resolves when the dialog has been accepted.

defaultValue()

The default value of the prompt, or an empty string if the dialog is not a prompt.

dismiss()

A promise which will resolve once the dialog has been dismissed

message()

The message displayed in the dialog.

type()

The type of the dialog.