1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

LibWeb+WebContent+WebDriver: Implement Accept Alert

This commit is contained in:
Timothy Flynn 2022-11-16 07:24:22 -05:00 committed by Linus Groh
parent 7cf2feb047
commit 3e7d633954
9 changed files with 45 additions and 0 deletions

View file

@ -1360,6 +1360,23 @@ Messages::WebDriverClient::DismissAlertResponse WebDriverConnection::dismiss_ale
return JsonValue {};
}
// 16.2 Accept Alert, https://w3c.github.io/webdriver/#accept-alert
Messages::WebDriverClient::AcceptAlertResponse WebDriverConnection::accept_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. Accept the current user prompt.
m_page_host.accept_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()
{