1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

WebDriver: Add computedrole endpoint

This commit is contained in:
Jonah 2023-01-15 10:26:08 -06:00 committed by Tim Flynn
parent 3fb4d50982
commit 569b56e2ad
7 changed files with 33 additions and 0 deletions

View file

@ -1172,6 +1172,25 @@ Messages::WebDriverClient::IsElementEnabledResponse WebDriverConnection::is_elem
return enabled;
}
// 12.4.9 Get Computed Role, https://w3c.github.io/webdriver/#dfn-get-computed-role
Messages::WebDriverClient::GetComputedRoleResponse WebDriverConnection::get_computed_role(DeprecatedString const& element_id)
{
// 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. Handle any user prompts and return its value if it is an error.
TRY(handle_any_user_prompts());
// 3. Let element be the result of trying to get a known connected element with url variable element id.
auto* element = TRY(get_known_connected_element(element_id));
// 4. Let role be the result of computing the WAI-ARIA role of element.
auto role = element->role_or_default();
// 5. Return success with data role.
return DeprecatedString { role };
}
// 12.5.1 Element Click, https://w3c.github.io/webdriver/#element-click
Messages::WebDriverClient::ClickResponse WebDriverConnection::click(DeprecatedString const& element_id)
{