Skip to content

Improve how selectors are generated #625

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

Open
allansson opened this issue Apr 4, 2025 · 0 comments
Open

Improve how selectors are generated #625

allansson opened this issue Apr 4, 2025 · 0 comments
Assignees

Comments

@allansson
Copy link
Collaborator

What?

The recorder needs to generate robust selectors. The current logic generates selectors that are technically unique but very generic, e.g. a bare a element selector. These selectors are easy to break and don't handle changes to the DOM well.

Ideally we could wait for getBy* support from k6-browser but we currently don't have an ETA on that.

Meanwhile, we need to have something better.

Criteria for considering it closed

Generated selectors should be robust enough to survive most DOM changes.

  • They shouldn't rely on bare element tag selectors i.e. h1.
  • They should steer clear of class names from popular framewords such as Tailwind or Emotion.
  • Ideally they should steer clear of class names that are heavily used in a page.
  • Prefer certain attributes and patterns, e.g. data-testid and a[href='/abcdef']
@allansson allansson added this to the Browser Recording milestone Apr 4, 2025
@allansson allansson self-assigned this Apr 4, 2025
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

1 participant