headless-recorder icon indicating copy to clipboard operation
headless-recorder copied to clipboard

Default to text selectors for Playwright

Open RyKilleen opened this issue 4 years ago • 2 comments

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 avatar Sep 29 '21 20:09 RyKilleen

@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.

ianaya89 avatar Sep 30 '21 15:09 ianaya89

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

dolfje avatar Nov 09 '21 17:11 dolfje

https://github.com/checkly/headless-recorder/issues/232

ianaya89 avatar Dec 16 '22 13:12 ianaya89