headless-recorder
headless-recorder copied to clipboard
Default to text selectors for Playwright
Is it technically feasible to default to something like button:has-text("Log In") instead of incredibly long, unmaintainable selectors? Some way of defaulting to the shortest text-based selector when possible? I'd love to be able to use this extension while also following Playwright's best practices of using text in all possible cases.
@RyKilleen did you try (or is possible for you) to use a data attribute?
You can set something like data-testid to your HTML elements and then configure the extension to use it in the options page.
Once is enabled, data attributes will take precedence over other selectors.
With pull request https://github.com/checkly/headless-recorder/pull/178 it is possible to set a custom resolver. In the pull request, you can also find code that you have to set as custom resolver
https://github.com/checkly/headless-recorder/issues/232