mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:37:35 +00:00
Browser+WebContent+WebDriver: Move Get Element Attribute to WebContent
In doing so, this also implements a FIXME to handle boolean attributes.
This commit is contained in:
parent
7b1f3b7253
commit
1bc94e135f
16 changed files with 37 additions and 67 deletions
|
@ -659,12 +659,11 @@ Web::WebDriver::Response Client::handle_is_element_selected(Vector<StringView> c
|
|||
|
||||
// 12.4.2 Get Element Attribute, https://w3c.github.io/webdriver/#dfn-get-element-attribute
|
||||
// GET /session/{session id}/element/{element id}/attribute/{name}
|
||||
Web::WebDriver::Response Client::handle_get_element_attribute(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_get_element_attribute(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/attribute/<name>");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
auto result = TRY(session->get_element_attribute(payload, parameters[1], parameters[2]));
|
||||
return make_json_value(result);
|
||||
return session->web_content_connection().get_element_attribute(parameters[1], parameters[2]);
|
||||
}
|
||||
|
||||
// 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property
|
||||
|
|
|
@ -323,34 +323,6 @@ static ErrorOr<i32, Web::WebDriver::Error> get_known_connected_element(StringVie
|
|||
return maybe_element_id.release_value();
|
||||
}
|
||||
|
||||
// 12.4.2 Get Element Attribute, https://w3c.github.io/webdriver/#dfn-get-element-attribute
|
||||
Web::WebDriver::Response Session::get_element_attribute(JsonValue const&, StringView parameter_element_id, StringView name)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
||||
// FIXME: 2. Handle any user prompts and return its value if it is an error.
|
||||
|
||||
// 3. Let element be the result of trying to get a known connected element with url variable element id.
|
||||
auto element_id = TRY(get_known_connected_element(parameter_element_id));
|
||||
|
||||
// FIXME: The case that the element does not exist is not handled at all and null is returned in that case.
|
||||
|
||||
// 4. Let result be the result of the first matching condition:
|
||||
// -> FIXME: If name is a boolean attribute
|
||||
// NOTE: LibWeb doesn't know about boolean attributes directly
|
||||
// "true" (string) if the element has the attribute, otherwise null.
|
||||
// -> Otherwise
|
||||
// The result of getting an attribute by name name.
|
||||
auto result = m_browser_connection->get_element_attribute(element_id, name);
|
||||
|
||||
if (!result.has_value())
|
||||
return JsonValue(AK::JsonValue::Type::Null);
|
||||
|
||||
// 5. Return success with data result.
|
||||
return JsonValue(result.release_value());
|
||||
}
|
||||
|
||||
// 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property
|
||||
Web::WebDriver::Response Session::get_element_property(JsonValue const&, StringView parameter_element_id, StringView name)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
Web::WebDriver::Response get_window_handle();
|
||||
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();
|
||||
Web::WebDriver::Response get_window_handles() const;
|
||||
Web::WebDriver::Response get_element_attribute(JsonValue const& payload, StringView element_id, StringView name);
|
||||
Web::WebDriver::Response get_element_property(JsonValue const& payload, StringView element_id, StringView name);
|
||||
Web::WebDriver::Response get_element_css_value(JsonValue const& payload, StringView element_id, StringView property_name);
|
||||
Web::WebDriver::Response get_element_text(JsonValue const& payload, StringView element_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue