Provides helper methods for traversing and querying the visual tree in headless tests. Simplifies common patterns for finding controls, validating tree structure, and debugging.
public static class VisualTreeTestHelper
kind:method, kind:property, kind:ctor. Press Esc to clear.Contains<T>(Visual)Checks if a visual contains a descendant of a specific type.ContainsNamed(Visual, String)Checks if a visual contains a descendant with a specific name.Count<T>(Visual)Counts all descendants of a specific type.FindAll<T>(Visual, Boolean)Finds all descendants of a specific type in the visual tree.FindAll<T>(Visual, Func<T, Boolean>, Boolean)Finds all descendants matching a predicate.FindAncestor<T>(Visual, Boolean)Finds the first ancestor of a specific type.FindAncestor<T>(Visual, Func<T, Boolean>, Boolean)Finds an ancestor matching a predicate.FindByClass<T>(Visual, String)Finds controls by CSS classes.FindByClasses<T>(Visual, String[])Finds controls that have all specified CSS classes.FindByName(Visual, String)Finds a control by its Name property in the visual tree.FindByName<T>(Visual, String)Finds a control by its Name property with a specific type.FindByProperty<T, TProperty>(Visual, AvaloniaProperty<TProperty>, TProperty)Finds controls by a specific property value.FindByPseudoClass<T>(Visual, String)Finds controls in a specific pseudo-class state.FindByTag(Visual, Object)Finds controls by Tag property.FindDisabled<T>(Visual)Finds all disabled controls of a specific type.FindEnabled<T>(Visual)Finds all enabled controls of a specific type.FindFirst<T>(Visual, Boolean)Finds the first descendant of a specific type in the visual tree.FindFirst<T>(Visual, Func<T, Boolean>, Boolean)Finds the first descendant matching a predicate.FindFirstByProperty<T, TProperty>(Visual, AvaloniaProperty<TProperty>, TProperty)Finds the first control with a specific property value.FindFocusable<T>(Visual)Finds all focusable controls of a specific type.FindFocused<T>(Visual)Finds all focused controls (should typically be 0 or 1).FindHidden<T>(Visual)Finds all hidden (not visible) controls of a specific type.FindVisible<T>(Visual)Finds all visible controls of a specific type.GetAncestors<T>(Visual)Gets all ancestors of a specific type.GetBoundsRelativeTo(Visual, Visual)Gets the bounds of a visual in the coordinate space of another visual.GetByName<T>(Visual, String)Gets a control by name, throwing if not found.GetCenter(Visual)Gets the center point of a visual.GetCenterRelativeTo(Visual, Visual)Gets the center point of a visual relative to another visual.GetChildAt(Visual, Int32)Gets a child at a specific index.GetChildAt<T>(Visual, Int32)Gets a child at a specific index, cast to a type.GetChildCount(Visual)Gets the number of direct children.GetChildren<T>(Visual)Gets the direct children of a specific type.GetDescendantCount(Visual)Gets the number of descendants (all levels).GetDetailedPathString(Visual)Gets a detailed path string including names where available.GetFirstChild<T>(Visual)Gets the first child of a specific type.GetLastChild<T>(Visual)Gets the last child of a specific type.GetNamedControls(Visual)Gets all named controls in the tree. If duplicate names exist, only the first occurrence is kept.GetPathFromRoot(Visual)Gets the path from root to the specified visual.GetPathString(Visual)Gets the path as type names for debugging.GetTypeSummary(Visual)Gets a summary of control types in the tree.HasAncestor<T>(Visual)Checks if the visual has an ancestor of a specific type.HitTest(Visual, Point)Gets the visual at a specific point in the visual's coordinate space.HitTestAll(Visual, Point)Gets all visuals at a specific point.HitTestAllControls(Visual, Point)Gets all controls at a specific point.HitTestControl(Visual, Point)Gets the control at a specific point.IsVisibleWithin(Visual, Visual)Checks if a visual is within the visible bounds of an ancestor.MatchesStructure(Visual, Type[])Checks if the tree structure matches expected types at each level.PrintTree(Visual, Int32)Prints the visual tree structure to a string for debugging.