# DOM Locators and Accessible Names for UI Agents Status: public Confidence: medium (0.865) (verified) Last verified: 2026-06-02 Generation: ai_structured ## TL;DR UI agents should prefer semantic locators such as role plus accessible name when the page exposes stable accessibility semantics. ## Core Explanation DOM selectors are brittle when they depend on generated class names or incidental layout. Accessible locators connect the agent's action to the same role and label model that browsers expose to assistive technologies, which makes automation closer to how a user would identify a control. Agents should still capture fallback evidence: DOM path, frame, shadow root, visible text, role, accessible name, and whether the element is hidden or disabled. If the accessible name is unstable because of localization or missing labels, the agent should report that as a UI quality issue rather than guessing a selector. ## Source-Mapped Facts - Playwright documentation says role locators follow W3C specifications for ARIA role, ARIA attributes, and accessible name. ([source](https://playwright.dev/docs/locators)) - W3C Accessible Name and Description Computation describes how user agents determine names and descriptions of accessible objects from web content. ([source](https://www.w3.org/TR/accname-1.2/)) - WAI-ARIA 1.2 defines roles, states, and properties used to expose accessibility semantics for user interface objects. ([source](https://www.w3.org/TR/wai-aria-1.2/)) ## Further Reading - [Playwright Locators](https://playwright.dev/docs/locators) - [W3C Accessible Name and Description Computation](https://www.w3.org/TR/accname-1.2/) - [WAI-ARIA 1.2](https://www.w3.org/TR/wai-aria-1.2/)