mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
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:
1 parent
b8bb44cf61
commit
cb880edf44
4 files changed
+20
-3
No files matched your search
@@ -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
|
||||
|
||||
@@ -16,7 +16,8 @@ func TestTranslateStringSelector_KnownKeys(t *testing.T) {
|
||||
{`text:Say "hi"`, `//*[normalize-space(text())='Say "hi"']`, true},
|
||||
{`text:it's`, `//*[normalize-space(text())="it's"]`, true},
|
||||
{`text:it's "fine"`, `//*[normalize-space(text())=concat("it's ", '"', "fine", '"', "")]`, true},
|
||||
{"desc:logout", `[aria-label="logout"]`, false},
|
||||
// desc also accepts an iOS merged label, the way internal/hierarchy does.
|
||||
{"desc:logout", `:is([aria-label="logout"], [aria-label^="logout, "])`, false},
|
||||
{"label:logout", `[aria-label="logout"]`, false},
|
||||
{"accessibilityLabel:logout", `[aria-label="logout"]`, false},
|
||||
{"aria-label:Sign in", `[aria-label="Sign in"]`, false},
|
||||
|
||||
Reference in new issue
Block a user