summaryrefslogtreecommitdiff
path: root/Userland/Services/WebDriver/Session.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-09 15:18:28 -0500
committerLinus Groh <mail@linusgroh.de>2022-11-10 13:10:16 +0000
commit5a750dc58cebd46c378772e33668cd53101133ef (patch)
tree46201195dc5c78fd7ab8613236bc7aea83f4c584 /Userland/Services/WebDriver/Session.cpp
parent6dca784fc44149b514c21a7a73da2356f1b2d57a (diff)
downloadserenity-5a750dc58cebd46c378772e33668cd53101133ef.zip
WebContent+WebDriver: Move Find Element From Element to WebContent
Diffstat (limited to 'Userland/Services/WebDriver/Session.cpp')
-rw-r--r--Userland/Services/WebDriver/Session.cpp49
1 files changed, 0 insertions, 49 deletions
diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp
index aa79b3edd5..3a5b89465f 100644
--- a/Userland/Services/WebDriver/Session.cpp
+++ b/Userland/Services/WebDriver/Session.cpp
@@ -447,55 +447,6 @@ ErrorOr<Vector<Session::LocalElement>, Web::WebDriver::Error> Session::locator_s
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnsupportedOperation, "Not implemented: locator strategy XPath");
}
-// 12.3.4 Find Element From Element, https://w3c.github.io/webdriver/#dfn-find-element-from-element
-Web::WebDriver::Response Session::find_element_from_element(JsonValue const& payload, StringView parameter_element_id)
-{
- if (!payload.is_object())
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object");
-
- auto const& properties = payload.as_object();
- // 1. Let location strategy be the result of getting a property called "using".
- if (!properties.has("using"sv))
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "No property called 'using' present");
- auto const& maybe_location_strategy = properties.get("using"sv);
- if (!maybe_location_strategy.is_string())
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Property 'using' is not a String");
-
- auto location_strategy = maybe_location_strategy.to_string();
-
- // 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
- if (!s_locator_strategies.first_matching([&](LocatorStrategy const& match) { return match.name == location_strategy; }).has_value())
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "No valid location strategy");
-
- // 3. Let selector be the result of getting a property called "value".
- // 4. If selector is undefined, return error with error code invalid argument.
- if (!properties.has("value"sv))
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "No property called 'value' present");
- auto const& maybe_selector = properties.get("value"sv);
- if (!maybe_selector.is_string())
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Property 'value' is not a String");
-
- auto selector = maybe_selector.to_string();
-
- // 5. If the current browsing context is no longer open, return error with error code no such window.
- TRY(check_for_open_top_level_browsing_context_or_return_error());
-
- // FIXME: 6. Handle any user prompts and return its value if it is an error.
-
- // 7. Let start node be the result of trying to get a known connected element with url variable element id.
- auto element_id = TRY(get_known_connected_element(parameter_element_id));
- LocalElement start_node = { element_id };
-
- // 8. Let result be the value of trying to Find with start node, location strategy, and selector.
- auto result = TRY(find(start_node, location_strategy, selector));
-
- // 9. If result is empty, return error with error code no such element. Otherwise, return the first element of result.
- if (result.is_empty())
- return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, "The requested element does not exist");
-
- return JsonValue(result.at(0));
-}
-
// 12.3.5 Find Elements From Element, https://w3c.github.io/webdriver/#dfn-find-elements-from-element
Web::WebDriver::Response Session::find_elements_from_element(JsonValue const& payload, StringView parameter_element_id)
{