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 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 prop(
element: Element,
key: String,
) -> option.Option(node.PropValue)
Get a prop value by key.
pub fn text(element: Element) -> option.Option(String)
Extract text content from an element. Checks props in order: “content”, “label”, “value”, “placeholder”.