You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: 'Customize how Cypress chooses selectors in Studio and Selector Playground by setting your preferred selector strategy.'
3
+
description: 'Customize how Cypress chooses selectors in Studio and cy.prompt() by setting your preferred selector strategy.'
4
4
sidebar_label: ElementSelector
5
5
sidebar_position: 105
6
6
---
@@ -9,7 +9,7 @@ sidebar_position: 105
9
9
10
10
# Cypress.ElementSelector
11
11
12
-
The ElementSelector API lets you define how Cypress selects elements in tools like [Cypress Studio](/app/guides/cypress-studio) and the [Selector Playground](/app/core-concepts/open-mode#Selector-Playground) (which will be replaced by Cypress Studio once it is no longer experimental).
12
+
The ElementSelector API lets you define how Cypress selects elements in tools like [Cypress Studio](/app/guides/cypress-studio) and [cy.prompt()](/api/commands/prompt).
13
13
14
14
By setting your own selector strategy, you can control which attributes Cypress prioritizes (like `data-*`, `id`, or `aria-label`) when generating selectors. This helps you enforce consistency, improve test readability, and make generated tests more resilient to changes in your HTML.
15
15
@@ -72,7 +72,7 @@ The [jQuery element](http://api.jquery.com/Types/#jQuery) for which you want to
72
72
73
73
### Set custom selector priority
74
74
75
-
You can customize how Cypress generates selectors by defining a priority order for which attributes to prefer. This affects the selectors you see in tools like [Cypress Studio](/app/guides/cypress-studio) and the [Selector Playground](/app/core-concepts/open-mode#Selector-Playground) (which will be replaced by Cypress Studio once it is no longer experimental).
75
+
You can customize how Cypress generates selectors by defining a priority order for which attributes to prefer. This affects the selectors you see in tools like [Cypress Studio](/app/guides/cypress-studio) and [cy.prompt()](/api/commands/prompt)
76
76
77
77
For example, this config tells Cypress to prefer semantic and accessibility attributes before falling back to styling details like class names.
|[`Cypress.arch`](/api/cypress-api/arch)| CPU architecture name of the underlying OS, as returned from Node's `os.arch()`. |
197
-
|[`Cypress.browser`](/api/cypress-api/browser)| Information about the current browser, such as browser family and version. |
198
-
|[`Cypress.Commands`](/api/cypress-api/custom-commands)| Create new custom commands and extend or override existing ones. |
199
-
|[`Cypress.config()`](/api/cypress-api/config)| Get and set Cypress configuration from inside your tests. |
200
-
|[`Cypress.Cookies.debug()`](/api/cypress-api/cookies)| Generate console logs whenever a cookie is modified. |
201
-
|[`Cypress.currentRetry`](/api/cypress-api/currentretry)| A number representing the current test retry count. |
202
-
|[`Cypress.currentTest`](/api/cypress-api/currenttest)| An object with information about the currently executing test. |
203
-
|[`Cypress.log`](/api/cypress-api/cypress-log)| This is the internal API for controlling what gets printed to the Command Log. Useful when writing your own custom commands. |
204
-
|[`Cypress.dom`](/api/cypress-api/dom)| A collection of DOM related helper methods. |
205
-
|[`Cypress.ElementSelector`](/api/cypress-api/element-selector-api)| Configure selector priority used by [Cypress Studio](/app/guides/cypress-studio) and [Selector Playground](/app/core-concepts/open-mode#Selector-Playground).|
206
-
|[`Cypress.env`](/api/cypress-api/env)| Get environment variables from inside your tests. |
207
-
|[`Cypress.isBrowser()`](/api/cypress-api/isbrowser)| Checks if the current browser matches the given name or filter. |
208
-
|[`Cypress.isCy()`](/api/cypress-api/iscy)| checks if a variable is a valid instance of cy or a cy chainable. |
209
-
|[`Cypress.Keyboard.defaults()`](/api/cypress-api/keyboard-api)| Set default values for how the `.type()` command is executed. |
210
-
|[`Cypress.platform`](/api/cypress-api/platform)| The underlaying OS name, as returned by Node's `os.platform()`. |
211
-
|[`Cypress.require`](/api/cypress-api/require)| Enables utilizing dependencies within the [cy.origin()](/api/commands/origin) callback function. |
212
-
|[`Cypress.Screenshot.defaults()`](/api/cypress-api/screenshot-api)| Set defaults for screenshots captured by the `.screenshot()` command and the automatic screenshots taken during test failures. |
213
-
|[`Cypress.session`](/api/cypress-api/session)| A collection of helper methods related to the `.session()` command. |
214
-
|[`Cypress.spec`](/api/cypress-api/spec)| An object with information about the currently executing spec file. |
215
-
|[`Cypress.testingType`](/api/cypress-api/testing-type)| The current testing type, eg. `"e2e"` or `"component". |
216
-
|[`Cypress.version`](/api/cypress-api/version)| The current Cypress version. |
|[`Cypress.arch`](/api/cypress-api/arch)| CPU architecture name of the underlying OS, as returned from Node's `os.arch()`. |
197
+
|[`Cypress.browser`](/api/cypress-api/browser)| Information about the current browser, such as browser family and version. |
198
+
|[`Cypress.Commands`](/api/cypress-api/custom-commands)| Create new custom commands and extend or override existing ones. |
199
+
|[`Cypress.config()`](/api/cypress-api/config)| Get and set Cypress configuration from inside your tests. |
200
+
|[`Cypress.Cookies.debug()`](/api/cypress-api/cookies)| Generate console logs whenever a cookie is modified. |
201
+
|[`Cypress.currentRetry`](/api/cypress-api/currentretry)| A number representing the current test retry count. |
202
+
|[`Cypress.currentTest`](/api/cypress-api/currenttest)| An object with information about the currently executing test. |
203
+
|[`Cypress.log`](/api/cypress-api/cypress-log)| This is the internal API for controlling what gets printed to the Command Log. Useful when writing your own custom commands. |
204
+
|[`Cypress.dom`](/api/cypress-api/dom)| A collection of DOM related helper methods. |
205
+
|[`Cypress.ElementSelector`](/api/cypress-api/element-selector-api)| Configure selector priority used by [Cypress Studio](/app/guides/cypress-studio) and [cy.prompt()](/api/commands/prompt). |
206
+
|[`Cypress.env`](/api/cypress-api/env)| Get environment variables from inside your tests. |
207
+
|[`Cypress.isBrowser()`](/api/cypress-api/isbrowser)| Checks if the current browser matches the given name or filter. |
208
+
|[`Cypress.isCy()`](/api/cypress-api/iscy)| checks if a variable is a valid instance of cy or a cy chainable. |
209
+
|[`Cypress.Keyboard.defaults()`](/api/cypress-api/keyboard-api)| Set default values for how the `.type()` command is executed. |
210
+
|[`Cypress.platform`](/api/cypress-api/platform)| The underlaying OS name, as returned by Node's `os.platform()`. |
211
+
|[`Cypress.require`](/api/cypress-api/require)| Enables utilizing dependencies within the [cy.origin()](/api/commands/origin) callback function. |
212
+
|[`Cypress.Screenshot.defaults()`](/api/cypress-api/screenshot-api)| Set defaults for screenshots captured by the `.screenshot()` command and the automatic screenshots taken during test failures. |
213
+
|[`Cypress.session`](/api/cypress-api/session)| A collection of helper methods related to the `.session()` command. |
214
+
|[`Cypress.spec`](/api/cypress-api/spec)| An object with information about the currently executing spec file. |
215
+
|[`Cypress.testingType`](/api/cypress-api/testing-type)| The current testing type, eg. `"e2e"` or `"component". |
216
+
|[`Cypress.version`](/api/cypress-api/version)| The current Cypress version. |
0 commit comments