fix(spec): match a merged label by its leading name on web too

The native desc rule accepts the label or the label at the head of an iOS
merged label; both web translators compared the whole string, so the same
selector matched natively and missed on web. The live-page parity test
caught it.
This commit is contained in:
pj committed 2026-08-13 00:41:23 +05:30
1 parent b8bb44cf61
commit cb880edf44
4 files changed
+20 -3

No files matched your search

+6 -1
View File
@@ -40,7 +40,12 @@ func TranslateStringSelector(selector string) (string, bool, error) {
return cssEscape(value), false, nil
case "text":
return `//*[normalize-space(text())=` + xpathStringLiteral(value) + `]`, true, nil
case "desc", "label", "content-desc", "accessibilityLabel", "accessibilityText", "ariaLabel", "aria-label":
case "desc":
// Mirrors the native rule: the label itself, or the label at the head of
// an iOS merged label ("account_card:7, Tim, $100").
escaped := cssEscape(value)
return `:is([aria-label="` + escaped + `"], [aria-label^="` + escaped + `, "])`, false, nil
case "label", "content-desc", "accessibilityLabel", "accessibilityText", "ariaLabel", "aria-label":
return `[aria-label="` + cssEscape(value) + `"]`, false, nil
case "descPrefix":
return `[aria-label^="` + cssEscape(value) + `"]`, false, nil