mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
WebDriver+Browser: Implement GET /session/{id}/source
This commit is contained in:
parent
82af1557dd
commit
61d0b66bfb
9 changed files with 49 additions and 0 deletions
|
@ -631,6 +631,10 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
|
|||
return active_tab().view().get_element_tag_name(element_id);
|
||||
};
|
||||
|
||||
new_tab.webdriver_endpoints().on_serialize_source = [this]() {
|
||||
return active_tab().view().serialize_source();
|
||||
};
|
||||
|
||||
new_tab.webdriver_endpoints().on_execute_script = [this](String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async) {
|
||||
return active_tab().view().webdriver_execute_script(body, json_arguments, timeout, async);
|
||||
};
|
||||
|
|
|
@ -117,6 +117,18 @@ void WebDriverConnection::minimize_window()
|
|||
browser_window->set_minimized(true);
|
||||
}
|
||||
|
||||
Messages::WebDriverSessionClient::SerializeSourceResponse WebDriverConnection::serialize_source()
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: serialize_source");
|
||||
if (auto browser_window = m_browser_window.strong_ref()) {
|
||||
auto& tab = browser_window->active_tab();
|
||||
if (tab.webdriver_endpoints().on_serialize_source)
|
||||
return { tab.webdriver_endpoints().on_serialize_source() };
|
||||
}
|
||||
|
||||
return { {} };
|
||||
}
|
||||
|
||||
Messages::WebDriverSessionClient::ExecuteScriptResponse WebDriverConnection::execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)
|
||||
{
|
||||
dbgln("WebDriverConnection: execute_script");
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
virtual void set_window_position(Gfx::IntPoint const&) override;
|
||||
virtual void maximize_window() override;
|
||||
virtual void minimize_window() override;
|
||||
virtual Messages::WebDriverSessionClient::SerializeSourceResponse serialize_source() override;
|
||||
virtual Messages::WebDriverSessionClient::ExecuteScriptResponse execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async) override;
|
||||
virtual Messages::WebDriverSessionClient::GetAllCookiesResponse get_all_cookies() override;
|
||||
virtual Messages::WebDriverSessionClient::GetNamedCookieResponse get_named_cookie(String const& name) override;
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
Function<String(i32 element_id, String const&)> on_get_computed_value_for_element;
|
||||
Function<String(i32 element_id)> on_get_element_text;
|
||||
Function<String(i32 element_id)> on_get_element_tag_name;
|
||||
Function<String()> on_serialize_source;
|
||||
Function<Messages::WebContentServer::WebdriverExecuteScriptResponse(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)> on_execute_script;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ endpoint WebDriverSessionClient {
|
|||
set_window_position(Gfx::IntPoint position) =|
|
||||
maximize_window() =|
|
||||
minimize_window() =|
|
||||
serialize_source() => (String source)
|
||||
execute_script(String body, Vector<String> json_arguments, Optional<u64> timeout, bool async) => (Web::WebDriver::ExecuteScriptResultType result_type, String json_result)
|
||||
get_all_cookies() => (Vector<Web::Cookie::Cookie> cookies)
|
||||
get_named_cookie(String name) => (Optional<Web::Cookie::Cookie> cookie)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue