Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/cypress-api/element-selector-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ With the default selector priority, Cypress prioritizes `id`, so the selector wo

The [jQuery element](http://api.jquery.com/Types/#jQuery) for which you want to retrieve a selector.

## Where to configure

Call `Cypress.ElementSelector.defaults({ ... })` once in your [support file](/app/references/configuration). You want this to load before your specs and do **not** want to set this inside `describe`, `it`, `before`, `beforeEach`, or similar test hooks.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not set it in hooks or code?


`Cypress.ElementSelector` is only available in support and spec code, not in the Node process that loads your cypress configuration.

## Examples

### Set custom selector priority
Expand Down
2 changes: 1 addition & 1 deletion docs/app/tooling/ai-skills.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Before writing a single line, the cypress-author skill reads your project: your

In practice, that means:

- **Selectors that hold up.** The skill follows a defined hierarchy (`data-cy`, `data-test`, `data-testid`) and flags selectors that are likely to break under normal maintenance.
- **Selectors that hold up.** The skill attempts to follow the selector priority configured with [`Cypress.ElementSelector`](/api/cypress-api/element-selector-api) and flags selectors that are likely to break under normal maintenance.
- **Code that fits your project.** It matches your language (TypeScript or JavaScript) and existing type patterns, and reuses your existing helpers and custom commands rather than reinventing them.
- **Only APIs your Cypress version supports.** The skill checks your Cypress version and limits suggestions to what is actually available to your project.

Expand Down