mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:47:34 +00:00
WebDriver+Browser: Implement GET /session/{id}/element/{id}/selected
This commit is contained in:
parent
4067138702
commit
2d75229192
9 changed files with 55 additions and 0 deletions
|
@ -607,6 +607,10 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
|
|||
return active_tab().view().query_selector_all(start_node_id, selector);
|
||||
};
|
||||
|
||||
new_tab.webdriver_endpoints().on_is_element_selected = [this](i32 element_id) {
|
||||
return active_tab().view().is_element_selected(element_id);
|
||||
};
|
||||
|
||||
new_tab.webdriver_endpoints().on_get_element_attribute = [this](i32 element_id, String const& name) {
|
||||
return active_tab().view().get_element_attribute(element_id, name);
|
||||
};
|
||||
|
|
|
@ -218,6 +218,17 @@ Messages::WebDriverSessionClient::QuerySelectorAllResponse WebDriverConnection::
|
|||
return { {} };
|
||||
}
|
||||
|
||||
Messages::WebDriverSessionClient::IsElementSelectedResponse WebDriverConnection::is_element_selected(i32 element_id)
|
||||
{
|
||||
dbgln("WebDriverConnection: is_element_selected {}", element_id);
|
||||
if (auto browser_window = m_browser_window.strong_ref()) {
|
||||
auto& tab = browser_window->active_tab();
|
||||
if (tab.webdriver_endpoints().on_is_element_selected)
|
||||
return { tab.webdriver_endpoints().on_is_element_selected(element_id) };
|
||||
}
|
||||
return { false };
|
||||
}
|
||||
|
||||
Messages::WebDriverSessionClient::GetElementAttributeResponse WebDriverConnection::get_element_attribute(i32 element_id, String const& name)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: get_element_attribute");
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
virtual void update_cookie(Web::Cookie::Cookie const&) override;
|
||||
virtual Messages::WebDriverSessionClient::GetDocumentElementResponse get_document_element() override;
|
||||
virtual Messages::WebDriverSessionClient::QuerySelectorAllResponse query_selector_all(i32 start_node_id, String const& selector) override;
|
||||
virtual Messages::WebDriverSessionClient::IsElementSelectedResponse is_element_selected(i32 element_id) override;
|
||||
virtual Messages::WebDriverSessionClient::GetElementAttributeResponse get_element_attribute(i32 element_id, String const& name) override;
|
||||
virtual Messages::WebDriverSessionClient::GetElementPropertyResponse get_element_property(i32 element_id, String const& name) override;
|
||||
virtual Messages::WebDriverSessionClient::GetActiveDocumentsTypeResponse get_active_documents_type() override;
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
|
||||
Function<Optional<i32>()> on_get_document_element;
|
||||
Function<Optional<Vector<i32>>(i32 start_node_id, String const&)> on_query_selector_all;
|
||||
Function<bool(i32 element_id)> on_is_element_selected;
|
||||
Function<Optional<String>(i32 element_id, String const&)> on_get_element_attribute;
|
||||
Function<Optional<String>(i32 element_id, String const&)> on_get_element_property;
|
||||
Function<String()> on_get_active_documents_type;
|
||||
|
|
|
@ -31,6 +31,7 @@ endpoint WebDriverSessionClient {
|
|||
update_cookie(Web::Cookie::Cookie cookie) =|
|
||||
get_document_element() => (Optional<i32> document_element_id)
|
||||
query_selector_all(i32 start_node_id, String selector) => (Optional<Vector<i32>> elements_ids)
|
||||
is_element_selected(i32 element_id) => (bool selected)
|
||||
get_element_attribute(i32 element_id, String name) => (Optional<String> atttibute)
|
||||
get_element_property(i32 element_id, String name) => (Optional<String> property)
|
||||
get_active_documents_type() => (String type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue