feat(locator): add description option to getByRole#40083
feat(locator): add description option to getByRole#40083Skn0tt wants to merge 6 commits intomicrosoft:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Would it be worth adding a test for an element with both aria-description and aria-describedby attributes?
When both attributes are set, and aria-describedby has a valid target element, then aria-description is ignored.
aria-describedby can also have multiple IDs.
It looks like if the aria-describedby has, for example, the same ID twice, then the accessible description will have the same text twice as well.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| candidates.push([{ engine: 'internal:role', selector: `${ariaRole}[name=${escapeForAttributeSelector(alternative.text, false)}]`, score: kRoleWithNameScore - alternative.scoreBonus }]); | ||
| const ariaDescription = getElementAccessibleDescription(element, false); | ||
| if (ariaDescription) { | ||
| candidates.push([{ engine: 'internal:role', selector: `${ariaRole}[name=${escapeForAttributeSelector(ariaName, true)}][description=${escapeForAttributeSelector(ariaDescription, true)}]`, score: kRoleWithNameScoreExact + 1 }]); |
There was a problem hiding this comment.
Not sure we want both the name and the description in the same generated selector.
packages/isomorphic/locatorParser.ts
Outdated
| .replace(/filter\(,?has2=([^)]+)\)/g, 'internal:has=$1') | ||
| .replace(/filter\(,?hasnot2=([^)]+)\)/g, 'internal:has-not=$1') | ||
| .replace(/,exact=false/g, '') | ||
| .replace(/(,name=\$\d+)(,description=\$\d+),exact=true/g, '$1s$2s') |
There was a problem hiding this comment.
Not sure I understand this one - could you please elaborate or point to a test this covers?
There was a problem hiding this comment.
added a comment, without it we can't parse this properly: https://github.com/Skn0tt/playwright/blob/3c76ebc10a48da7deeab4a0b0d80916c634b5ffe/tests/library/locator-generator.spec.ts#L248-L249
Test results for "MCP"1 failed 6519 passed, 383 skipped Merge workflow run. |
Test results for "tests 1"6 flaky39241 passed, 846 skipped Merge workflow run. |
Fixes: #39932