Uh oh!
There was an error while loading. Please reload this page.
feat(test): allow testIdAttribute to be a comma-separated list of names - #40844
Conversation
When an array is provided, `page.getByTestId(...)` matches elements with any of the listed attributes; codegen/recorder consider each configured attribute when generating `getByTestId(...)` locators. Fixesmicrosoft#23827
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Dmitry Gozman (dgozman)
left a comment
There was a problem hiding this comment.
So many changes everywhere! I wonder if we should just support syntax like data-testid;data-test-id and only make a few small targeted changes.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Avoid bumping the trace format: serialize the array of test-id attribute names as a comma-separated string in the trace, parse it back when rendering. HTML attribute names cannot contain commas, so the delimiter is unambiguous.
Encode multiple test id attribute names as a comma-separated string rather than changing types throughout the protocol/client. Splitting happens at three consumers (getByTestIdSelector, selectorGenerator, locatorParser). HTML attribute names cannot contain commas, so the delimiter is unambiguous.
Produce a single-clause internal:testid=[name=value] selector with the attribute name quoted when it contains commas, and split inside the engine. Removes splitting from getByTestIdSelector and the locatorParser replacement.
Default to 'data-testid' so tests calling parseLocator without the third argument keep working. Also extract encodeTestIdAttributeName helper to dedupe the conditional-quote pattern.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Per review feedback, don't touch the deprecated top-level Selectors API documentation.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "MCP"3 failed 7083 passed, 1104 skipped Merge workflow run. |
Test results for "tests 1"4 flaky41822 passed, 850 skipped Merge workflow run. |
fc39cf7
into
microsoft:mainUh oh!
There was an error while loading. Please reload this page.
David Rodriguez (drod1107)
commented
Jul 24, 2026
Just dropping by to say thanks - this feature saved my bacon today. ❤️ |
Summary
testIdAttributeconfig option still typed as a singlestring. Multiple attribute names can be specified by joining them with a comma, e.g.'data-pw,data-ti'—page.getByTestId(...)then matches elements with any of the listed attributes.getByTestId(...)candidates.,happens in three internal consumers: theinternal:testidselector engine, the codegen candidate builder, and the locator parser.Fixes#23827