Skip to content

Dialog

Namespace: PuppeteerSharp

public abstract class Dialog

Dialog objects are dispatched by page via the ‘dialog’ event.

Inheritance: object

Derived: BidiDialog, CdpDialog

Example

An example of using Dialog class:

Page.Dialog += async (sender, e) =>
{
await e.Dialog.Accept();
}
await Page.EvaluateExpressionAsync("alert('yo');");

View source

public Dialog(DialogType type, string message, string defaultValue)

Initializes a new instance of the Dialog class.

Parameters

Name Type Description
type DialogType Type.
message string Message.
defaultValue string Default value.

View source

public string DefaultValue { get; set; }

If dialog is prompt, returns default prompt value. Otherwise, returns empty string.

Value: string — The default value.

View source

public DialogType DialogType { get; set; }

Dialog’s type, can be one of alert, beforeunload, confirm or prompt.

Value: DialogType — The type of the dialog.

View source

public bool Handled { get; }

Gets a value indicating whether the dialog has been handled.

Value: bool — true if the dialog has already been accepted or dismissed; otherwise, false.

View source

public string Message { get; set; }

A message displayed in the dialog.

Value: string — The message.

View source

public Task Accept(string promptText = "")

Accept the Dialog.

Parameters

Name Type Description
promptText string A text to enter in prompt. Does not cause any effects if the dialog’s type is not prompt.

Returns: Task — Task which resolves when the dialog has been accepted.

View source

public Task Dismiss()

Dismiss the dialog.

Returns: Task — Task which resolves when the dialog has been dismissed.

View source

Made with love by Dario Kondratiuk