Overview
Expands a collapsible element such as a disclosure triangle, tree item, or accordion section. This reveals child elements that were previously hidden.Syntax
Parameters
Element reference from snapshot (must support expand/collapse)
Response
Response Fields
The action performed (
expand)The element reference that was expanded
Element state after expansion
role(string): Element rolestates(string[]): Includes “expanded”
AX-First Strategy
The expand command:- Checks if already expanded via
kAXValueAttributeor states - If collapsed, performs
kAXPressAction - Tries clicking disclosure triangle if present
- Verifies state changed to expanded
Usage Examples
Expand Folder in Finder
Expand Tree Item
Expand Disclosure Section
Expand Nested Hierarchy
Supported Element Types
| Role | Expand Behavior |
|---|---|
disclosure triangle | Reveals child elements |
row (with disclosure) | Expands tree row |
group | Expands collapsible group |
outline | Expands outline row |
button (disclosure) | Opens section |
State Changes
After expansion:- Element state includes
"expanded" - Child elements become visible in accessibility tree
- Disclosure triangle icon changes (▶ → ▼)
- Subsequent snapshot shows newly visible children
Error Cases
| Error Code | Cause | Recovery |
|---|---|---|
ELEMENT_NOT_FOUND | Ref doesn’t exist in current refmap | Run snapshot to refresh |
STALE_REF | Element no longer matches saved ref | Run snapshot and use new ref |
ACTION_FAILED | Element cannot be expanded | Already expanded or not expandable |
ACTION_NOT_SUPPORTED | Element type doesn’t support expand | Wrong element type |
Verifying Expansion
Common Use Cases
- File Navigation: Expand folders in Finder
- Tree Views: Expand hierarchy in IDEs and file browsers
- Settings: Reveal advanced options
- Outlines: Expand outline sections
- Sidebars: Open sidebar categories
Expand + Snapshot Pattern
Idempotency
Expand is typically idempotent:Expand vs Collapse
| Command | Behavior | Icon Change |
|---|---|---|
expand | Reveals children | ▶ → ▼ |
collapse | Hides children | ▼ → ▶ |
Notes
- Always snapshot after expand to capture newly visible children
- Some apps animate expansion; add
waitafter expand - Expanded state persists until collapsed or app restart
- Use
is @ref expandedto check state before expanding - Some disclosure triangles are separate clickable elements
- Expanding large trees may be slow; consider timeout
- Pair with
collapseto manage tree visibility