mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
WebDriver: Implement all modes for handling the current user prompt
This commit is contained in:
parent
adc7977ec7
commit
37c4bf3afd
1 changed files with 24 additions and 11 deletions
|
@ -1527,27 +1527,40 @@ ErrorOr<void, Web::WebDriver::Error> WebDriverConnection::handle_any_user_prompt
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 2. Perform the following substeps based on the current session’s user prompt handler:
|
// 2. Perform the following substeps based on the current session’s user prompt handler:
|
||||||
|
switch (m_unhandled_prompt_behavior) {
|
||||||
// FIXME: The user prompt handler is a capability-level configuration, which we have no support
|
|
||||||
// for yet. It defaults to "dismiss and notify", so that is all that is handled here.
|
|
||||||
|
|
||||||
// -> dismiss state
|
// -> dismiss state
|
||||||
// Dismiss the current user prompt.
|
case Web::WebDriver::UnhandledPromptBehavior::Dismiss:
|
||||||
|
// Dismiss the current user prompt.
|
||||||
|
m_page_host.dismiss_dialog();
|
||||||
|
break;
|
||||||
|
|
||||||
// -> accept state
|
// -> accept state
|
||||||
// Accept the current user prompt.
|
case Web::WebDriver::UnhandledPromptBehavior::Accept:
|
||||||
|
// Accept the current user prompt.
|
||||||
|
m_page_host.accept_dialog();
|
||||||
|
break;
|
||||||
|
|
||||||
// -> dismiss and notify state
|
// -> dismiss and notify state
|
||||||
if (true) {
|
case Web::WebDriver::UnhandledPromptBehavior::DismissAndNotify:
|
||||||
// Dismiss the current user prompt.
|
// Dismiss the current user prompt.
|
||||||
m_page_host.dismiss_dialog();
|
m_page_host.dismiss_dialog();
|
||||||
|
|
||||||
// Return an annotated unexpected alert open error.
|
// Return an annotated unexpected alert open error.
|
||||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv);
|
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv);
|
||||||
}
|
|
||||||
// -> accept and notify state
|
// -> accept and notify state
|
||||||
// Accept the current user prompt.
|
case Web::WebDriver::UnhandledPromptBehavior::AcceptAndNotify:
|
||||||
// Return an annotated unexpected alert open error.
|
// Accept the current user prompt.
|
||||||
|
m_page_host.accept_dialog();
|
||||||
|
|
||||||
|
// Return an annotated unexpected alert open error.
|
||||||
|
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv);
|
||||||
|
|
||||||
// -> ignore state
|
// -> ignore state
|
||||||
// Return an annotated unexpected alert open error.
|
case Web::WebDriver::UnhandledPromptBehavior::Ignore:
|
||||||
|
// Return an annotated unexpected alert open error.
|
||||||
|
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv);
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Return success.
|
// 3. Return success.
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue