1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

LibWeb+WebContent+WebDriver: Implement Dismiss Alert

This commit is contained in:
Timothy Flynn 2022-11-16 07:15:57 -05:00 committed by Linus Groh
parent 159dcb9507
commit 7cf2feb047
7 changed files with 33 additions and 0 deletions

View file

@ -1343,6 +1343,23 @@ Messages::WebDriverClient::DeleteAllCookiesResponse WebDriverConnection::delete_
return JsonValue {};
}
// 16.1 Dismiss Alert, https://w3c.github.io/webdriver/#dismiss-alert
Messages::WebDriverClient::DismissAlertResponse WebDriverConnection::dismiss_alert()
{
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
TRY(ensure_open_top_level_browsing_context());
// 2. If there is no current user prompt, return error with error code no such alert.
if (!m_page_host.has_pending_dialog())
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchAlert, "No user dialog is currently open"sv);
// 3. Dismiss the current user prompt.
m_page_host.dismiss_dialog();
// 4. Return success with data null.
return JsonValue {};
}
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
Messages::WebDriverClient::TakeScreenshotResponse WebDriverConnection::take_screenshot()
{