plushie/testing/element
Element: a query-friendly wrapper around a tree Node.
Elements provide convenient accessors for testing: find by ID, extract text content, read props, and traverse children.
Types
Values
pub fn a11y(
element: Element,
) -> dict.Dict(String, node.PropValue)
Get the a11y props dict from an element.
Returns an empty dict if no a11y key is set.
pub fn child_at(
element: Element,
index: Int,
) -> option.Option(Element)
Get a child element by index.
pub fn find(
in root: node.Node,
id target: String,
) -> option.Option(Element)
Find an element by ID in a normalized tree.
pub fn find_all(
element: Element,
predicate: fn(Element) -> Bool,
) -> List(Element)
Collect all descendant elements matching a predicate.
pub fn find_within(
element: Element,
target: String,
) -> option.Option(Element)
Find a descendant element by ID within this element’s subtree.
pub fn has_children(element: Element) -> Bool
Check if the element has any children.
pub fn local_id(element: Element) -> String
Get the local ID (last segment after “/” and “#”).
pub fn prop(
element: Element,
key: String,
) -> option.Option(node.PropValue)
Get a prop value by key.
pub fn resolved_a11y(
element: Element,
) -> dict.Dict(String, node.PropValue)
Return the resolved a11y dict for this element.
Layers render-pipeline inference (placeholder -> description for
text-entry widgets, alt -> label for media widgets) on top of the
normalized a11y prop. Kept aligned with the Rust SDK’s
resolve_a11y_for_node so cross-SDK parity holds.
pub fn text(element: Element) -> option.Option(String)
Extract text content from an element. Checks props in order: “content”, “label”, “value”, “placeholder”.