Table of Contents

Class Dialog

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

Dialog objects are dispatched by page via the 'dialog' event.

public abstract class Dialog
Inheritance
Dialog
Derived

Examples

An example of using Dialog class:

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

Constructors

Dialog(DialogType, string, string)

Initializes a new instance of the Dialog class.

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

Parameters

type DialogType

Type.

message string

Message.

defaultValue string

Default value.

Properties

DefaultValue

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

public string DefaultValue { get; set; }

Property Value

string

The default value.

DialogType

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

public DialogType DialogType { get; set; }

Property Value

DialogType

The type of the dialog.

Message

A message displayed in the dialog.

public string Message { get; set; }

Property Value

string

The message.

Methods

Accept(string)

Accept the Dialog.

public Task Accept(string promptText = "")

Parameters

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.

Dismiss()

Dismiss the dialog.

public Task Dismiss()

Returns

Task

Task which resolves when the dialog has been dismissed.