2022-11-08 10:03:07 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
|
|
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibIPC/ConnectionToServer.h>
|
2022-11-09 15:02:38 -05:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
#include <LibWeb/WebDriver/ElementLocationStrategies.h>
|
2022-11-08 10:03:07 -05:00
|
|
|
#include <LibWeb/WebDriver/Response.h>
|
|
|
|
#include <WebContent/Forward.h>
|
|
|
|
#include <WebContent/WebDriverClientEndpoint.h>
|
|
|
|
#include <WebContent/WebDriverServerEndpoint.h>
|
|
|
|
|
|
|
|
namespace WebContent {
|
|
|
|
|
|
|
|
class WebDriverConnection final
|
|
|
|
: public IPC::ConnectionToServer<WebDriverClientEndpoint, WebDriverServerEndpoint> {
|
|
|
|
C_OBJECT_ABSTRACT(WebDriverConnection)
|
|
|
|
|
|
|
|
public:
|
2022-11-09 09:56:20 -05:00
|
|
|
static ErrorOr<NonnullRefPtr<WebDriverConnection>> connect(ConnectionFromClient& web_content_client, PageHost& page_host, String const& webdriver_ipc_path);
|
2022-11-08 10:03:07 -05:00
|
|
|
virtual ~WebDriverConnection() = default;
|
|
|
|
|
|
|
|
private:
|
2022-11-09 09:56:20 -05:00
|
|
|
WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, ConnectionFromClient& web_content_client, PageHost& page_host);
|
2022-11-08 10:03:07 -05:00
|
|
|
|
|
|
|
virtual void die() override { }
|
2022-11-08 14:14:29 -05:00
|
|
|
|
|
|
|
virtual void close_session() override;
|
2022-11-08 10:42:12 -05:00
|
|
|
virtual void set_is_webdriver_active(bool) override;
|
2022-11-08 12:58:24 -05:00
|
|
|
virtual Messages::WebDriverClient::NavigateToResponse navigate_to(JsonValue const& payload) override;
|
2022-11-08 13:06:22 -05:00
|
|
|
virtual Messages::WebDriverClient::GetCurrentUrlResponse get_current_url() override;
|
2022-11-09 09:56:20 -05:00
|
|
|
virtual Messages::WebDriverClient::GetWindowRectResponse get_window_rect() override;
|
|
|
|
virtual Messages::WebDriverClient::SetWindowRectResponse set_window_rect(JsonValue const& payload) override;
|
2022-11-09 11:00:53 -05:00
|
|
|
virtual Messages::WebDriverClient::MaximizeWindowResponse maximize_window() override;
|
|
|
|
virtual Messages::WebDriverClient::MinimizeWindowResponse minimize_window() override;
|
2022-11-09 15:02:38 -05:00
|
|
|
virtual Messages::WebDriverClient::FindElementResponse find_element(JsonValue const& payload) override;
|
2022-11-09 15:08:49 -05:00
|
|
|
virtual Messages::WebDriverClient::FindElementsResponse find_elements(JsonValue const& payload) override;
|
2022-11-09 15:18:28 -05:00
|
|
|
virtual Messages::WebDriverClient::FindElementFromElementResponse find_element_from_element(JsonValue const& payload, String const& element_id) override;
|
2022-11-09 15:25:23 -05:00
|
|
|
virtual Messages::WebDriverClient::FindElementsFromElementResponse find_elements_from_element(JsonValue const& payload, String const& element_id) override;
|
2022-11-08 12:58:24 -05:00
|
|
|
|
|
|
|
ErrorOr<void, Web::WebDriver::Error> ensure_open_top_level_browsing_context();
|
2022-11-09 09:56:20 -05:00
|
|
|
void restore_the_window();
|
2022-11-09 11:00:53 -05:00
|
|
|
Gfx::IntRect maximize_the_window();
|
|
|
|
Gfx::IntRect iconify_the_window();
|
2022-11-09 15:02:38 -05:00
|
|
|
ErrorOr<JsonArray, Web::WebDriver::Error> find(Web::DOM::ParentNode& start_node, Web::WebDriver::LocationStrategy using_, StringView value);
|
2022-11-08 10:03:07 -05:00
|
|
|
|
2022-11-09 09:56:20 -05:00
|
|
|
ConnectionFromClient& m_web_content_client;
|
2022-11-08 10:03:07 -05:00
|
|
|
PageHost& m_page_host;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|