1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:27:45 +00:00

LibWeb+WebDriver: Move WebDriverError to Web::WebDriver::Error

This is to prepare for WebContent becoming the WebDriver client.
This commit is contained in:
Timothy Flynn 2022-11-08 10:10:27 -05:00 committed by Tim Flynn
parent a4fc7dbf6d
commit 0246abec80
10 changed files with 283 additions and 284 deletions

View file

@ -11,9 +11,9 @@
#include <AK/Error.h>
#include <AK/JsonValue.h>
#include <AK/RefPtr.h>
#include <LibWeb/WebDriver/Error.h>
#include <WebDriver/BrowserConnection.h>
#include <WebDriver/TimeoutsConfiguration.h>
#include <WebDriver/WebDriverError.h>
#include <unistd.h>
namespace WebDriver {
@ -34,55 +34,55 @@ public:
i32 id;
};
ErrorOr<Window*, WebDriverError> current_window();
ErrorOr<void, WebDriverError> check_for_open_top_level_browsing_context_or_return_error();
ErrorOr<Window*, Web::WebDriver::Error> current_window();
ErrorOr<void, Web::WebDriver::Error> check_for_open_top_level_browsing_context_or_return_error();
String const& current_window_handle() { return m_current_window_handle; }
ErrorOr<void> start();
ErrorOr<void> stop();
JsonObject get_timeouts();
ErrorOr<JsonValue, WebDriverError> set_timeouts(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> navigate_to(JsonValue const& url);
ErrorOr<JsonValue, WebDriverError> get_current_url();
ErrorOr<JsonValue, WebDriverError> back();
ErrorOr<JsonValue, WebDriverError> forward();
ErrorOr<JsonValue, WebDriverError> refresh();
ErrorOr<JsonValue, WebDriverError> get_title();
ErrorOr<JsonValue, WebDriverError> get_window_handle();
ErrorOr<void, Variant<WebDriverError, Error>> close_window();
ErrorOr<JsonValue, WebDriverError> get_window_handles() const;
ErrorOr<JsonValue, WebDriverError> get_window_rect();
ErrorOr<JsonValue, WebDriverError> set_window_rect(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> maximize_window();
ErrorOr<JsonValue, WebDriverError> minimize_window();
ErrorOr<JsonValue, WebDriverError> find_element(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> find_elements(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> find_element_from_element(JsonValue const& payload, StringView parameter_element_id);
ErrorOr<JsonValue, WebDriverError> find_elements_from_element(JsonValue const& payload, StringView parameter_element_id);
ErrorOr<JsonValue, WebDriverError> is_element_selected(StringView element_id);
ErrorOr<JsonValue, WebDriverError> get_element_attribute(JsonValue const& payload, StringView element_id, StringView name);
ErrorOr<JsonValue, WebDriverError> get_element_property(JsonValue const& payload, StringView element_id, StringView name);
ErrorOr<JsonValue, WebDriverError> get_element_css_value(JsonValue const& payload, StringView element_id, StringView property_name);
ErrorOr<JsonValue, WebDriverError> get_element_text(JsonValue const& payload, StringView element_id);
ErrorOr<JsonValue, WebDriverError> get_element_tag_name(JsonValue const& payload, StringView element_id);
ErrorOr<JsonValue, WebDriverError> get_element_rect(StringView element_id);
ErrorOr<JsonValue, WebDriverError> is_element_enabled(StringView element_id);
ErrorOr<JsonValue, WebDriverError> get_source();
ErrorOr<JsonValue, WebDriverError> execute_script(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> execute_async_script(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> get_all_cookies();
ErrorOr<JsonValue, WebDriverError> get_named_cookie(String const& name);
ErrorOr<JsonValue, WebDriverError> add_cookie(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> delete_cookie(StringView name);
ErrorOr<JsonValue, WebDriverError> delete_all_cookies();
ErrorOr<JsonValue, WebDriverError> take_screenshot();
ErrorOr<JsonValue, WebDriverError> take_element_screenshot(StringView element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> set_timeouts(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> navigate_to(JsonValue const& url);
ErrorOr<JsonValue, Web::WebDriver::Error> get_current_url();
ErrorOr<JsonValue, Web::WebDriver::Error> back();
ErrorOr<JsonValue, Web::WebDriver::Error> forward();
ErrorOr<JsonValue, Web::WebDriver::Error> refresh();
ErrorOr<JsonValue, Web::WebDriver::Error> get_title();
ErrorOr<JsonValue, Web::WebDriver::Error> get_window_handle();
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();
ErrorOr<JsonValue, Web::WebDriver::Error> get_window_handles() const;
ErrorOr<JsonValue, Web::WebDriver::Error> get_window_rect();
ErrorOr<JsonValue, Web::WebDriver::Error> set_window_rect(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> maximize_window();
ErrorOr<JsonValue, Web::WebDriver::Error> minimize_window();
ErrorOr<JsonValue, Web::WebDriver::Error> find_element(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> find_elements(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> find_element_from_element(JsonValue const& payload, StringView parameter_element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> find_elements_from_element(JsonValue const& payload, StringView parameter_element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> is_element_selected(StringView element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_attribute(JsonValue const& payload, StringView element_id, StringView name);
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_property(JsonValue const& payload, StringView element_id, StringView name);
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_css_value(JsonValue const& payload, StringView element_id, StringView property_name);
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_text(JsonValue const& payload, StringView element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_tag_name(JsonValue const& payload, StringView element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_rect(StringView element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> is_element_enabled(StringView element_id);
ErrorOr<JsonValue, Web::WebDriver::Error> get_source();
ErrorOr<JsonValue, Web::WebDriver::Error> execute_script(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> execute_async_script(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> get_all_cookies();
ErrorOr<JsonValue, Web::WebDriver::Error> get_named_cookie(String const& name);
ErrorOr<JsonValue, Web::WebDriver::Error> add_cookie(JsonValue const& payload);
ErrorOr<JsonValue, Web::WebDriver::Error> delete_cookie(StringView name);
ErrorOr<JsonValue, Web::WebDriver::Error> delete_all_cookies();
ErrorOr<JsonValue, Web::WebDriver::Error> take_screenshot();
ErrorOr<JsonValue, Web::WebDriver::Error> take_element_screenshot(StringView element_id);
private:
void delete_cookies(Optional<StringView> const& name = {});
ErrorOr<JsonArray, WebDriverError> find(LocalElement const& start_node, StringView location_strategy, StringView selector);
ErrorOr<JsonArray, Web::WebDriver::Error> find(LocalElement const& start_node, StringView location_strategy, StringView selector);
using ElementLocationStrategyHandler = ErrorOr<Vector<LocalElement>, WebDriverError> (Session::*)(LocalElement const&, StringView);
using ElementLocationStrategyHandler = ErrorOr<Vector<LocalElement>, Web::WebDriver::Error> (Session::*)(LocalElement const&, StringView);
struct LocatorStrategy {
String name;
ElementLocationStrategyHandler handler;
@ -90,11 +90,11 @@ private:
static Vector<LocatorStrategy> s_locator_strategies;
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_css_selectors(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_link_text(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_partial_link_text(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_tag_name(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_x_path(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, Web::WebDriver::Error> locator_strategy_css_selectors(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, Web::WebDriver::Error> locator_strategy_link_text(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, Web::WebDriver::Error> locator_strategy_partial_link_text(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, Web::WebDriver::Error> locator_strategy_tag_name(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, Web::WebDriver::Error> locator_strategy_x_path(LocalElement const&, StringView);
NonnullRefPtr<Client> m_client;
bool m_started { false };