You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have exact attribute to match accessible name more or less strict. And that is handy.
But I encountered difficulties locating elements that contain special characters like soft hyphen or zero width space.
Of course I can provide full name with \u00AD, but it is not readable: super\u00ADcali\u00ADfrag\u00ADilistic\u00ADexpial\u00ADidocious
vs supercalifragilisticexpialidocious
It would be nice to have another attribute working along with name and exact to handle those special non-printing/formatting characters.
Example
page.getByRole(AriaRole.COLUMNHEADER,
newPage.GetByRoleOptions().setName("supercalifragilisticexpialidocious")
.setIgnoreNonPrinting(true)) // or setIgnoreFormattingChars or whatever...
.click();
or may be set to true as default (similarly to exact).
Chaining with setExact(true) may be tricky here - maybe its naming is not the best for the purpose.
Motivation
To have more capabilities for locating elements by accessible name, keeping in mind this advice:
When to use role locators
We recommend prioritizing role locators to locate elements, as it is the closest way to how users and assistive technology perceive the page.
Users don't see and assistive technology does not read "\u00AD" etc...
The text was updated successfully, but these errors were encountered:
lubomsky
changed the title
[Feature]: Ignore special characters like softhyphens when locating by aria role name
[Feature]: Ignore special characters like softhyphens when locating by name
Feb 18, 2025
getElementAccessibleName refers to "Flat strings" from the ARIA spec:
Flat string: A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup.
I'd consider Softhyphens markup, so going by the spec we should probably remove them.
🚀 Feature Request
We have
exact
attribute to match accessible name more or less strict. And that is handy.But I encountered difficulties locating elements that contain special characters like soft hyphen or zero width space.
Of course I can provide full name with
\u00AD
, but it is not readable:super\u00ADcali\u00ADfrag\u00ADilistic\u00ADexpial\u00ADidocious
vs
supercalifragilisticexpialidocious
It would be nice to have another attribute working along with name and exact to handle those special non-printing/formatting characters.
Example
or may be set to true as default (similarly to
exact
).Chaining with
setExact(true)
may be tricky here - maybe its naming is not the best for the purpose.Motivation
To have more capabilities for locating elements by accessible name, keeping in mind this advice:
Users don't see and assistive technology does not read "\u00AD" etc...
The text was updated successfully, but these errors were encountered: