mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
WebDriver: Add computedlabel endpoint
This commit is contained in:
parent
307cd4a1da
commit
30ec59f163
Notes:
sideshowbarker
2024-07-17 18:08:55 +09:00
Author: https://github.com/Epigenetic Commit: https://github.com/SerenityOS/serenity/commit/30ec59f163 Pull-request: https://github.com/SerenityOS/serenity/pull/17541 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/trflynn89 ✅
7 changed files with 33 additions and 0 deletions
|
@ -87,6 +87,7 @@ static constexpr auto s_webdriver_endpoints = Array {
|
|||
ROUTE(GET, "/session/:session_id/element/:element_id/rect"sv, get_element_rect),
|
||||
ROUTE(GET, "/session/:session_id/element/:element_id/enabled"sv, is_element_enabled),
|
||||
ROUTE(GET, "/session/:session_id/element/:element_id/computedrole"sv, get_computed_role),
|
||||
ROUTE(GET, "/session/:session_id/element/:element_id/computedlabel"sv, get_computed_label),
|
||||
ROUTE(POST, "/session/:session_id/element/:element_id/click"sv, element_click),
|
||||
ROUTE(GET, "/session/:session_id/source"sv, get_source),
|
||||
ROUTE(POST, "/session/:session_id/execute/sync"sv, execute_script),
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
virtual Response get_element_rect(Parameters parameters, JsonValue payload) = 0;
|
||||
virtual Response is_element_enabled(Parameters parameters, JsonValue payload) = 0;
|
||||
virtual Response get_computed_role(Parameters parameters, JsonValue payload) = 0;
|
||||
virtual Response get_computed_label(Parameters parameters, JsonValue payload) = 0;
|
||||
virtual Response element_click(Parameters parameters, JsonValue payload) = 0;
|
||||
|
||||
// 13. Document, https://w3c.github.io/webdriver/#document
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -542,6 +542,15 @@ Web::WebDriver::Response Client::get_computed_role(Web::WebDriver::Parameters pa
|
|||
return session->web_content_connection().get_computed_role(parameters[1]);
|
||||
}
|
||||
|
||||
// 12.4.10 Get Computed Label, https://w3c.github.io/webdriver/#get-computed-label
|
||||
// GET /session/{session id}/element/{element id}/computedlabel
|
||||
Web::WebDriver::Response Client::get_computed_label(Web::WebDriver::Parameters parameters, JsonValue)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session id>/element/<element id>/computedlabel");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
return session->web_content_connection().get_computed_label(parameters[1]);
|
||||
}
|
||||
|
||||
// 12.5.1 Element Click, https://w3c.github.io/webdriver/#element-click
|
||||
// POST /session/{session id}/element/{element id}/click
|
||||
Web::WebDriver::Response Client::element_click(Web::WebDriver::Parameters parameters, JsonValue)
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
virtual Web::WebDriver::Response get_element_rect(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response is_element_enabled(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response get_computed_role(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response get_computed_label(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response element_click(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response get_source(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response execute_script(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
|
|
Loading…
Reference in a new issue