Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add byRole selector #11182

Closed
pavelfeldman opened this issue Jan 5, 2022 · 3 comments
Closed

[Feature] Add byRole selector #11182

pavelfeldman opened this issue Jan 5, 2022 · 3 comments
Assignees

Comments

@pavelfeldman
Copy link
Member

Extracted from #11145

https://testing-library.com/docs/queries/byrole/

@kevin940726
Copy link
Contributor

kevin940726 commented Feb 4, 2022

Just found this, and I want to shamelessly plug my experimental library role-selector here. It uses the @testing-library/dom under the hood to query the elements and compute their accessible attributes. An example selector will look like the following:

page.locator('role=button[name="My button"]');

Although the library will technically work in puppeteer or even jsdom, it's designed with playwright in mind, thus intentionally not implementing duplicated features like byText or visible, which can be chained with >>.

The selector syntax is similar to the React selectors or the Vue selectors but only supports accessible attributes. It can also use regex for strings to create the selector.

The library is still under development, but I plan to experiment with it in gutenberg's e2e test suites when we migrate to playwright (soon).

@kevin940726
Copy link
Contributor

Just want to update that we're now using the official built-in role selectors in Playwright and it works perfectly fine migrating from the role-selector package!

@aslushnikov aslushnikov added v1.25 and removed v1.24 labels Jul 12, 2022
@mxschmitt
Copy link
Member

Closing as per above, seems to be working as it is for a large customer.

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

No branches or pull requests

5 participants