mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
WebDriver: Add new WebDriver service
WebDriver aims to implement the WebDriver specification found at https://w3c.github.io/webdriver/webdriver-spec.html . It's an HTTP server that can create Browser sessions and control them. Co-authored-by: Florent Castelli <florent.castelli@gmail.com>
This commit is contained in:
parent
8c0f1da9f7
commit
80603f141a
12 changed files with 915 additions and 0 deletions
50
Userland/Services/WebDriver/Session.h
Normal file
50
Userland/Services/WebDriver/Session.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <WebDriver/BrowserConnection.h>
|
||||
#include <WebDriver/HttpError.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace WebDriver {
|
||||
|
||||
class Session {
|
||||
public:
|
||||
Session(unsigned session_id, NonnullRefPtr<Client> client);
|
||||
~Session();
|
||||
|
||||
unsigned session_id() const { return m_id; }
|
||||
|
||||
struct Window {
|
||||
String handle;
|
||||
bool is_open;
|
||||
};
|
||||
|
||||
HashMap<String, NonnullOwnPtr<Window>>& get_window_handles() { return m_windows; }
|
||||
Optional<Window*> get_window_object() { return m_windows.get(m_current_window_handle); }
|
||||
String get_window() { return m_current_window_handle; }
|
||||
|
||||
ErrorOr<void> start();
|
||||
ErrorOr<void> stop();
|
||||
ErrorOr<void, Variant<HttpError, Error>> delete_window();
|
||||
ErrorOr<JsonValue, HttpError> post_url(JsonValue const& url);
|
||||
ErrorOr<JsonValue, HttpError> get_title();
|
||||
|
||||
private:
|
||||
NonnullRefPtr<Client> m_client;
|
||||
bool m_started { false };
|
||||
unsigned m_id { 0 };
|
||||
HashMap<String, NonnullOwnPtr<Window>> m_windows;
|
||||
String m_current_window_handle;
|
||||
RefPtr<Core::LocalServer> m_local_server;
|
||||
RefPtr<BrowserConnection> m_browser_connection;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue