Overview
xa11y is a cross-platform accessibility client library. It reads accessibility trees exposed by other applications and lets you interact with UI elements — clicking buttons, reading text, filling fields — through a single, unified API.
xa11y/├── xa11y-core # Platform-independent types, traits, selector engine├── xa11y-macos # macOS backend (AXUIElement)├── xa11y-linux # Linux backend (AT-SPI2 via D-Bus)├── xa11y-windows # Windows backend (UI Automation)├── xa11y # Umbrella crate — re-exports core, picks the right backend└── xa11y-python # Python bindings via PyO3What It Does
Desktop operating systems expose UI structure through accessibility APIs (originally designed for screen readers). xa11y provides a clean abstraction over these platform-specific APIs:
| Platform | Underlying API |
|---|---|
| macOS | AXUIElement (Core Accessibility) |
| Windows | UI Automation |
| Linux | AT-SPI2 via D-Bus |
Selectors
xa11y uses a CSS-like selector syntax to query accessibility trees:
button # by rolebutton[name='Submit'] # role + exact attribute matchtextfield[name^='Search'] # starts-withtextfield[name*='email'] # contains (case-insensitive)button[name$='Cancel'] # ends-withgroup > button # direct childwindow button[name='OK'] # descendantbutton:nth(2) # 2nd matchSupported attributes: name, value, description, role.
Supported operators: = (exact), *= (contains), ^= (starts-with), $= (ends-with).
Pseudo-selectors: :nth(n) to select the nth match.
Supported Actions
| Action | Description |
|---|---|
press | Click / activate |
focus | Move keyboard focus |
blur | Remove keyboard focus |
toggle | Toggle a checkbox or switch |
expand / collapse | Expand or collapse a disclosure |
select | Select an item |
set_value | Set a text field’s value |
type_text | Type text into an element |
set_text_selection | Select a text range by offsets |
increment / decrement | Adjust a slider or stepper |
scroll | Scroll in a direction |
scroll_into_view | Scroll element into the viewport |
show_menu | Open a context menu |