diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 3600ab0409..73a2d7e49c 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -83,7 +84,7 @@ static JsonObject web_element_reference_object(Web::DOM::Node const& element) } // https://w3c.github.io/webdriver/#dfn-get-a-known-connected-element -static ErrorOr get_known_connected_element(StringView element_id) +static ErrorOr get_known_connected_element(StringView element_id) { // NOTE: The whole concept of "connected elements" is not implemented yet. See get_or_create_a_web_element_reference(). // For now the element is only represented by its ID. @@ -93,12 +94,10 @@ static ErrorOr get_known_connected auto* node = Web::DOM::Node::from_id(*element); - if (!node) + if (!node || !node->is_element()) return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, String::formatted("Could not find element with ID: {}", element_id)); - if (!is(node)) - return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, String::formatted("Element with ID is not a parent node: {}", element_id)); - return static_cast(node); + return static_cast(node); } static ErrorOr get_property(JsonValue const& payload, StringView key)