feat(chrome): translate idPrefix to a starts-with id match

This commit is contained in:
pj committed 2026-08-13 00:00:57 +05:30
1 parent 1fcb7a9f7d
commit 59975231ce
2 files changed
+5

No files matched your search

+2
View File
@@ -32,6 +32,8 @@ func TranslateStringSelector(selector string) (string, bool, error) {
switch kind { switch kind {
case "id", "resource-id": case "id", "resource-id":
return `[id="` + cssEscape(value) + `"]`, false, nil return `[id="` + cssEscape(value) + `"]`, false, nil
case "idPrefix":
return `[id^="` + cssEscape(value) + `"]`, false, nil
case "class": case "class":
return `[class~="` + cssEscape(value) + `"]`, false, nil return `[class~="` + cssEscape(value) + `"]`, false, nil
case "tag": case "tag":
+3
View File
@@ -21,6 +21,9 @@ func TestTranslateStringSelector_KnownKeys(t *testing.T) {
{"accessibilityLabel:logout", `[aria-label="logout"]`, false}, {"accessibilityLabel:logout", `[aria-label="logout"]`, false},
{"aria-label:Sign in", `[aria-label="Sign in"]`, false}, {"aria-label:Sign in", `[aria-label="Sign in"]`, false},
{"descPrefix:account:", `[aria-label^="account:"]`, false}, {"descPrefix:account:", `[aria-label^="account:"]`, false},
// Must stay the string pkg/spec/src/web-runtime.ts builds for the same
// selector; the two translators feed the same page.
{"idPrefix:customer_row_", `[id^="customer_row_"]`, false},
{"testTag:submit", `:is([data-testid="submit"], [id="submit"])`, false}, {"testTag:submit", `:is([data-testid="submit"], [id="submit"])`, false},
{"testID:submit", `[data-testid="submit"]`, false}, {"testID:submit", `[data-testid="submit"]`, false},
{"placeholder:Email", `[placeholder="Email"]`, false}, {"placeholder:Email", `[placeholder="Email"]`, false},