Skip to content

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 PyO3

What 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:

PlatformUnderlying API
macOSAXUIElement (Core Accessibility)
WindowsUI Automation
LinuxAT-SPI2 via D-Bus

Selectors

xa11y uses a CSS-like selector syntax to query accessibility trees:

button # by role
button[name='Submit'] # role + exact attribute match
textfield[name^='Search'] # starts-with
textfield[name*='email'] # contains (case-insensitive)
button[name$='Cancel'] # ends-with
group > button # direct child
window button[name='OK'] # descendant
button:nth(2) # 2nd match

Supported attributes: name, value, description, role. Supported operators: = (exact), *= (contains), ^= (starts-with), $= (ends-with). Pseudo-selectors: :nth(n) to select the nth match.

Supported Actions

ActionDescription
pressClick / activate
focusMove keyboard focus
blurRemove keyboard focus
toggleToggle a checkbox or switch
expand / collapseExpand or collapse a disclosure
selectSelect an item
set_valueSet a text field’s value
type_textType text into an element
set_text_selectionSelect a text range by offsets
increment / decrementAdjust a slider or stepper
scrollScroll in a direction
scroll_into_viewScroll element into the viewport
show_menuOpen a context menu