pub struct MatchedDialog {
pub dialog_type: DialogType,
pub message: String,
pub default_prompt: Option<String>,
pub url: String,
pub session: SessionHandle,
}expect only.Expand description
A JavaScript dialog observed via Page.javascriptDialogOpened.
The session handle is retained so Self::accept / Self::dismiss
can dispatch Page.handleJavaScriptDialog against the same target the
event arrived on. Consumed by value on accept/dismiss — each dialog can
only be handled once.
Debug is manually implemented since SessionHandle does not derive
it; the session is rendered as a placeholder.
Fields§
§dialog_type: DialogTypeDialog flavor (alert/beforeunload/confirm/prompt).
message: StringMessage text shown by the dialog.
default_prompt: Option<String>Default value for prompt(...) dialogs. None for alert/confirm/
beforeunload (which Chrome reports with an empty default).
url: StringURL of the page that opened the dialog.
session: SessionHandleSession this dialog arrived on. Retained so accept/dismiss dispatch against the correct target.
Implementations§
Source§impl MatchedDialog
impl MatchedDialog
Sourcepub async fn accept(self, prompt_text: Option<String>) -> Result<()>
pub async fn accept(self, prompt_text: Option<String>) -> Result<()>
Accept the dialog.
For prompt dialogs, pass the value to submit via prompt_text;
for alert/confirm/beforeunload, pass None. Dispatches
Page.handleJavaScriptDialog { accept: true, promptText }.
§Examples
let dialog = tab.expect_dialog().await?;
// ... trigger something that opens a prompt ...
dialog.accept(Some("Alice".into())).await?;Trait Implementations§
Source§impl Clone for MatchedDialog
impl Clone for MatchedDialog
Source§fn clone(&self) -> MatchedDialog
fn clone(&self) -> MatchedDialog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more