summaryrefslogtreecommitdiff
path: root/Userland/Services/WebContent
diff options
context:
space:
mode:
authorJonah <jonahshafran@gmail.com>2023-02-19 11:36:08 -0600
committerTim Flynn <trflynn89@pm.me>2023-02-19 13:28:01 -0500
commit30ec59f1632d29eb512357f1d9aed260e04b598a (patch)
tree5064f752f153c1c41bbdd6c7ca39a89b7b0c20ec /Userland/Services/WebContent
parent307cd4a1daa14b9e24221525fa6ae27de0201e95 (diff)
downloadserenity-30ec59f1632d29eb512357f1d9aed260e04b598a.zip
WebDriver: Add computedlabel endpoint
Diffstat (limited to 'Userland/Services/WebContent')
-rw-r--r--Userland/Services/WebContent/WebDriverClient.ipc1
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.cpp19
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.h1
3 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc
index afe2e8f868..cadb84b7ce 100644
--- a/Userland/Services/WebContent/WebDriverClient.ipc
+++ b/Userland/Services/WebContent/WebDriverClient.ipc
@@ -41,6 +41,7 @@ endpoint WebDriverClient {
get_element_rect(DeprecatedString element_id) => (Web::WebDriver::Response response)
is_element_enabled(DeprecatedString element_id) => (Web::WebDriver::Response response)
get_computed_role(DeprecatedString element_id) => (Web::WebDriver::Response response)
+ get_computed_label(DeprecatedString element_id) => (Web::WebDriver::Response response)
element_click(DeprecatedString element_id) => (Web::WebDriver::Response response)
get_source() => (Web::WebDriver::Response response)
execute_script(JsonValue payload) => (Web::WebDriver::Response response)
diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp
index 252226ab39..0361199cad 100644
--- a/Userland/Services/WebContent/WebDriverConnection.cpp
+++ b/Userland/Services/WebContent/WebDriverConnection.cpp
@@ -1258,6 +1258,25 @@ Messages::WebDriverClient::GetComputedRoleResponse WebDriverConnection::get_comp
return ""sv;
}
+// 12.4.10 Get Computed Label, https://w3c.github.io/webdriver/#get-computed-label
+Messages::WebDriverClient::GetComputedLabelResponse WebDriverConnection::get_computed_label(DeprecatedString const& element_id)
+{
+ // 1. If the current 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 element with url variable element id.
+ auto* element = TRY(get_known_connected_element(element_id));
+
+ // 4. Let label be the result of a Accessible Name and Description Computation for the Accessible Name of the element.
+ auto label = element->accessible_name(element->document()).release_value_but_fixme_should_propagate_errors();
+
+ // 5. Return success with data label.
+ return label.to_deprecated_string();
+}
+
// 12.5.1 Element Click, https://w3c.github.io/webdriver/#element-click
Messages::WebDriverClient::ElementClickResponse WebDriverConnection::element_click(DeprecatedString const& element_id)
{
diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h
index cf2627e439..e998ebf314 100644
--- a/Userland/Services/WebContent/WebDriverConnection.h
+++ b/Userland/Services/WebContent/WebDriverConnection.h
@@ -76,6 +76,7 @@ private:
virtual Messages::WebDriverClient::GetElementRectResponse get_element_rect(DeprecatedString const& element_id) override;
virtual Messages::WebDriverClient::IsElementEnabledResponse is_element_enabled(DeprecatedString const& element_id) override;
virtual Messages::WebDriverClient::GetComputedRoleResponse get_computed_role(DeprecatedString const& element_id) override;
+ virtual Messages::WebDriverClient::GetComputedLabelResponse get_computed_label(DeprecatedString const& element_id) override;
virtual Messages::WebDriverClient::ElementClickResponse element_click(DeprecatedString const& element_id) override;
virtual Messages::WebDriverClient::GetSourceResponse get_source() override;
virtual Messages::WebDriverClient::ExecuteScriptResponse execute_script(JsonValue const& payload) override;