Dialog
Namespace: PuppeteerSharp
public abstract class DialogDialog 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');");Constructors
Section titled “Constructors”Dialog(DialogType, string, string)
Section titled “Dialog(DialogType, string, string)”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. |
Properties
Section titled “Properties”DefaultValue
Section titled “DefaultValue”public string DefaultValue { get; set; }If dialog is prompt, returns default prompt value. Otherwise, returns empty string.
Value: string — The default value.
DialogType
Section titled “DialogType”public DialogType DialogType { get; set; }Dialog’s type, can be one of alert, beforeunload, confirm or prompt.
Value: DialogType — The type of the dialog.
Handled
Section titled “Handled”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.
Message
Section titled “Message”public string Message { get; set; }A message displayed in the dialog.
Value: string — The message.
Methods
Section titled “Methods”Accept(string)
Section titled “Accept(string)”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.
Dismiss()
Section titled “Dismiss()”public Task Dismiss()Dismiss the dialog.
Returns: Task — Task which resolves when the dialog has been dismissed.
Made with love by Dario Kondratiuk