Skip to content

fix(locator): render getByRole() with a regex name and a string description - #42780

Open
om singhal (Om-singhaI) wants to merge 1 commit into
microsoft:mainfrom
Om-singhaI:fix/locator-role-regex-name-string-description
Open

om singhal (Om-singhaI) wants to merge 1 commit into
microsoft:mainfrom
Om-singhaI:fix/locator-role-regex-name-string-description

Conversation

@Om-singhaI

Copy link
Copy Markdown
Contributor

Fixes #42779

getByRole() with a regex name and a string description (or the reverse) prints as the raw internal:role=... selector in toString(), expect errors and call logs.

The exactness check from #41035 compares caseSensitive for name and description. parseAttributeSelector() marks every regex as case sensitive, while a string without exact is "..."i. So the pair looks like a conflict, innerAsLocators() throws and asLocator() falls back to the selector.

Exactness only means something for strings. Now only string values set options.exact and take part in the conflict check. Real string conflicts from #41032 still come back raw. Before #41035, a string name with a regex description printed a wrong exact: true taken from the regex. Now it prints without it.

Testing:

…iption

The exactness check added for microsoft#41032 treated every regex as exact. So a
regex name next to a string description that isn't exact (or the other
way around) was reported as a conflict, and the locator was printed as
the raw internal:role selector. Only string values carry exactness now.
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

9 flaky ⚠️ [chromium-library] › library/video.spec.ts:690 › screencast › should capture full viewport `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-leaks.spec.ts:136 › expect should not leak `@webkit-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-test-update.spec.ts:202 › should update test locations `@ubuntu-latest-node22`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:189 › should show snapshots for steps `@windows-latest-node22`

52003 passed, 1247 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

8629 passed, 1446 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: getByRole() with a regex name and a string description prints the raw internal:role selector

1 participant