Skip to content

Use a Matcher as the parameter of QueryByRole::having_name - #31

Open
hovinen wants to merge 2 commits into
add-expect-no-matching-elementfrom
use-matcher-in-having-name
Open

hovinen wants to merge 2 commits into
add-expect-no-matching-elementfrom
use-matcher-in-having-name

Conversation

@hovinen

@hovinen hovinen commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Previously, the parameter to having_name was a string, which limited what could be done with the method and resulted in implicit behaviour. Namely, it was not clear that the a matching element would have an accessible name which contains the given string. Also, it was not possible to match by regex, which Playwright supports.

This changes the parameter into a Matcher<String> so that any matcher against strings can be used. This includes string containment, case-insensitive matching, and regular expressions.

@hovinen
hovinen added this pull request to stack #28 October 2, 2026 08:36
@hovinen
hovinen force-pushed the use-matcher-in-having-name branch from f8b60a4 to 35c2bdf Compare October 2, 2026 08:38
@hovinen hovinen self-assigned this Oct 3, 2026
@hovinen
hovinen requested a review from ealmloff October 3, 2026 11:46
@hovinen
hovinen force-pushed the use-matcher-in-having-name branch from 3b12a62 to 7973926 Compare October 16, 2026 19:03
Previously, the parameter to `having_name` was a string, which limited
what could be done with the method and resulted in implicit behaviour.
Namely, it was not clear that the a matching element would have an
accessible name which _contains_ the given string. Also, it was not
possible to match by regex, which Playwright
[supports](https://playwright.dev/docs/api/class-page#page-get-by-role-option-name).

This changes the parameter into a `Matcher<String>` so that _any_
matcher against strings can be used. This includes string containment,
case-insensitive matching, and regular expressions.
@hovinen
hovinen force-pushed the use-matcher-in-having-name branch from 7973926 to 11b4c31 Compare October 23, 2026 07:06
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.

2 participants