Function: byAriaLabel()
byAriaLabel(
value,relative?):CssLocator
Defined in: packages/core/src/locators/byAriaLabel.ts:36
Locate elements by the verbatim value of their aria-label attribute.
This matches the literal aria-label attribute only — it does NOT resolve the
computed accessible name (from aria-labelledby, an associated <label>, or
text content), which is not CSS-expressible and is the job of the forthcoming
name-aware findByRole (deferred — see #923).
Most commonly composed with byRole on the SAME element to tell two same-role siblings apart without relying on unstable (e.g. StyleX-hashed) class names. Use CssLocator.and to compound the matchers onto one element:
import { byAriaLabel, byRole } from '@atomic-testing/core';
const openButton = byRole('button').and(byAriaLabel('Open'));
const closeButton = byRole('button').and(byAriaLabel('Close'));
Parameters​
value​
string
Verbatim aria-label to match.
relative?​
LocatorRelativePosition = 'Descendant'
Relative position of the locator. Defaults to 'Descendant'.
Returns​
Example​
const close = byAriaLabel('Close');