diff --git a/docs/api/commands/end.mdx b/docs/api/commands/end.mdx index 84743a5e48..fdc8fc448c 100644 --- a/docs/api/commands/end.mdx +++ b/docs/api/commands/end.mdx @@ -1,11 +1,37 @@ --- title: 'end | Cypress Documentation' -description: End a chain of commands in Cypress. +description: 'Deprecated: End a chain of commands in Cypress.' sidebar_label: end +sidebar_custom_props: { 'deprecated_label': true } --- +:::caution + +Deprecated + +`.end()` was deprecated in Cypress `15.15.0` and will be removed in a future +major version. + +Instead of using `.end()` to break a chain, start a new chain of commands off +of `cy`: + +Before + +```javascript +cy.get('#user-cheryl').click().end().get('#user-charles').click() +``` + +After + +```javascript +cy.get('#user-cheryl').click() +cy.get('#user-charles').click() +``` + +::: + # end End a chain of commands. @@ -21,7 +47,7 @@ End a chain of commands. **Correct Usage** ```javascript -cy.contains('ul').end() // Yield 'null' instead of 'ul' element +cy.get('ul').end() // Yield 'null' instead of 'ul' element ``` **Incorrect Usage** @@ -40,18 +66,18 @@ cy.end() command to not receive what was yielded in the previous command. ```javascript -cy.contains('User: Cheryl') +cy.get('#user-cheryl') .click() .end() // yield null - .contains('User: Charles') - .click() // contains looks for content in document now + .get('#user-charles') + .click() // get looks for the element in the document now ``` Alternatively, you can always start a new chain of commands off of `cy`. ```javascript -cy.contains('User: Cheryl').click() -cy.contains('User: Charles').click() // contains looks for content in document now +cy.get('#user-cheryl').click() +cy.get('#user-charles').click() // get looks for the element in the document now ``` ## Rules diff --git a/docs/api/table-of-contents.mdx b/docs/api/table-of-contents.mdx index 9a8605f997..8f2ec4a7bd 100644 --- a/docs/api/table-of-contents.mdx +++ b/docs/api/table-of-contents.mdx @@ -111,56 +111,56 @@ Learn more about action commands in our Cypress has a variety of additional commands to help write tests. -| Command | Usage | -| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`.blur()`](/api/commands/blur) | Blur a focused element. Blur is not an action command, because users cannot directly unfocus an element, only focus a new one, but `.blur()` can be used as a testing shortcut. | -| [`.clearAllCookies()`](/api/commands/clearallcookies) | Clear all browser cookies. | -| [`.clearAllLocalStorage()`](/api/commands/clearalllocalstorage) | Clear `localStorage` data for all origins with which the test has interacted. | -| [`.clearAllSessionStorage()`](/api/commands/clearallsessionstorage) | Clear `sessionStorage` data for all origins with which the test has interacted. | -| [`.clearCookie()`](/api/commands/clearcookie) | Clear a specific browser cookie. | -| [`.clearCookies()`](/api/commands/clearcookies) | Clear browser cookies for a domain. | -| [`.clearLocalStorage()`](/api/commands/clearlocalstorage) | Clear data in `localStorage` for current domain and subdomain. | -| [`.clock()`](/api/commands/clock) | Override the browser's built-in time objects (`Date`, `setTimeout` and similar), allowing them to be controlled via `cy.tick()`. | -| [`.debug()`](/api/commands/debug) | Set a `debugger` statement and log what the previous command yields. | -| [`.each()`](/api/commands/each) | Invoke a callback on each item in an array. | -| [`.end()`](/api/commands/end) | Explicitly end a chain of Cypress commands. | -| [`.env()`](/api/commands/env) | Access secret environment variables in your tests. | -| [`.exec()`](/api/commands/exec) | Execute a system command. | -| [`.fixture()`](/api/commands/fixture) | Load a fixed set of data from disk. | -| [`.focus()`](/api/commands/focus) | Focus on a DOM element. Focus is not an action command, because users cannot directly focus an element, but `.focus()` can be used as a testing shortcut. | -| [`.getAllCookies()`](/api/commands/getallcookies) | Get all browser cookies. | -| [`.getAllLocalStorage()`](/api/commands/getalllocalstorage) | Get `localStorage` data for all origins with which the test has interacted. | -| [`.getAllSessionStorage()`](/api/commands/getallsessionstorage) | Get `sessionStorage` data for all origins with which the test has interacted. | -| [`.getCookie()`](/api/commands/getcookie) | Get a browser cookie by its name. | -| [`.getCookies()`](/api/commands/getcookies) | Get browser cookies for the current domain or a specified domain. | -| [`.go()`](/api/commands/go) | Navigate back or forward using the browser's history. | -| [`.hover()`](/api/commands/hover) | Cypress does not have a cy.hover() command. See [Issue #10](https://github.com/cypress-io/cypress/issues/10). | -| [`.intercept()`](/api/commands/intercept) | Spy and stub network requests and responses. | -| [`.log()`](/api/commands/log) | Print a message to the Cypress Command Log. | -| [`.mount()`](/api/commands/mount) | Mount a component for Cypress Component Testing. | -| [`.origin()`](/api/commands/origin) | Visit multiple domains of different origin in a single test. | -| [`.pause()`](/api/commands/pause) | Pause test execution, allowing interaction with the application under test before resuming. | -| [`.press()`](/api/commands/press) | Trigger native key events in your application to simulate real user keyboard interactions. | -| [`.prompt()`](/api/commands/prompt) | Use natural language to generate Cypress tests with AI. | -| [`.readFile()`](/api/commands/readfile) | Read a file from disk. | -| [`.reload()`](/api/commands/reload) | Reload the page. | -| [`.request()`](/api/commands/request) | Make an HTTP request. | -| [`.screenshot()`](/api/commands/screenshot) | Take a screenshot of the application under test. | -| [`.session()`](/api/commands/session) | Cache and restore cookies, localStorage, and sessionStorage (i.e. session data) in order to recreate a consistent browser context between tests. | -| [`.setCookie()`](/api/commands/setcookie) | Set a browser cookie. | -| [`.spread()`](/api/commands/spread) | Invoke a callback function with multiple arguments. Similar to `.then()`. | -| [`.spy()`](/api/commands/spy) | Wrap a method in a spy in order to record calls to the function. | -| [`.stub()`](/api/commands/stub) | Replace a method, record its usage and control its behavior. | -| [`.submit()`](/api/commands/submit) | Submit a form. | -| [`.task()`](/api/commands/task) | Execute code in Node via the `task` plugin event. | -| [`.then()`](/api/commands/then) | Invoke a callback function with the current subject, allowing you to execute code at specific points during a Cypress test. | -| [`.tick()`](/api/commands/tick) | Move time after overriding a native time functions with `cy.clock()`. | -| [`.viewport()`](/api/commands/viewport) | Control the size and orientation of the screen for your application. | -| [`.visit()`](/api/commands/visit) | Visit a remote URL. Many tests begin with this command. | -| [`.wait()`](/api/commands/wait) | Wait a number of milliseconds, or wait for an aliased resource to resolve. | -| [`.within()`](/api/commands/within) | Scopes all subsequent cy commands to within this element. Useful when working within a particular group of elements such as a `
`. | -| [`.wrap()`](/api/commands/wrap) | Yield the object passed into `.wrap()`. If the object is a promise, yield its resolved value. | -| [`.writeFile()`](/api/commands/writefile) | Write to a file with the specified contents. | +| Command | Usage | +| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`.blur()`](/api/commands/blur) | Blur a focused element. Blur is not an action command, because users cannot directly unfocus an element, only focus a new one, but `.blur()` can be used as a testing shortcut. | +| [`.clearAllCookies()`](/api/commands/clearallcookies) | Clear all browser cookies. | +| [`.clearAllLocalStorage()`](/api/commands/clearalllocalstorage) | Clear `localStorage` data for all origins with which the test has interacted. | +| [`.clearAllSessionStorage()`](/api/commands/clearallsessionstorage) | Clear `sessionStorage` data for all origins with which the test has interacted. | +| [`.clearCookie()`](/api/commands/clearcookie) | Clear a specific browser cookie. | +| [`.clearCookies()`](/api/commands/clearcookies) | Clear browser cookies for a domain. | +| [`.clearLocalStorage()`](/api/commands/clearlocalstorage) | Clear data in `localStorage` for current domain and subdomain. | +| [`.clock()`](/api/commands/clock) | Override the browser's built-in time objects (`Date`, `setTimeout` and similar), allowing them to be controlled via `cy.tick()`. | +| [`.debug()`](/api/commands/debug) | Set a `debugger` statement and log what the previous command yields. | +| [`.each()`](/api/commands/each) | Invoke a callback on each item in an array. | +| [`.end()`](/api/commands/end) deprecated | Explicitly end a chain of Cypress commands. | +| [`.env()`](/api/commands/env) | Access secret environment variables in your tests. | +| [`.exec()`](/api/commands/exec) | Execute a system command. | +| [`.fixture()`](/api/commands/fixture) | Load a fixed set of data from disk. | +| [`.focus()`](/api/commands/focus) | Focus on a DOM element. Focus is not an action command, because users cannot directly focus an element, but `.focus()` can be used as a testing shortcut. | +| [`.getAllCookies()`](/api/commands/getallcookies) | Get all browser cookies. | +| [`.getAllLocalStorage()`](/api/commands/getalllocalstorage) | Get `localStorage` data for all origins with which the test has interacted. | +| [`.getAllSessionStorage()`](/api/commands/getallsessionstorage) | Get `sessionStorage` data for all origins with which the test has interacted. | +| [`.getCookie()`](/api/commands/getcookie) | Get a browser cookie by its name. | +| [`.getCookies()`](/api/commands/getcookies) | Get browser cookies for the current domain or a specified domain. | +| [`.go()`](/api/commands/go) | Navigate back or forward using the browser's history. | +| [`.hover()`](/api/commands/hover) | Cypress does not have a cy.hover() command. See [Issue #10](https://github.com/cypress-io/cypress/issues/10). | +| [`.intercept()`](/api/commands/intercept) | Spy and stub network requests and responses. | +| [`.log()`](/api/commands/log) | Print a message to the Cypress Command Log. | +| [`.mount()`](/api/commands/mount) | Mount a component for Cypress Component Testing. | +| [`.origin()`](/api/commands/origin) | Visit multiple domains of different origin in a single test. | +| [`.pause()`](/api/commands/pause) | Pause test execution, allowing interaction with the application under test before resuming. | +| [`.press()`](/api/commands/press) | Trigger native key events in your application to simulate real user keyboard interactions. | +| [`.prompt()`](/api/commands/prompt) | Use natural language to generate Cypress tests with AI. | +| [`.readFile()`](/api/commands/readfile) | Read a file from disk. | +| [`.reload()`](/api/commands/reload) | Reload the page. | +| [`.request()`](/api/commands/request) | Make an HTTP request. | +| [`.screenshot()`](/api/commands/screenshot) | Take a screenshot of the application under test. | +| [`.session()`](/api/commands/session) | Cache and restore cookies, localStorage, and sessionStorage (i.e. session data) in order to recreate a consistent browser context between tests. | +| [`.setCookie()`](/api/commands/setcookie) | Set a browser cookie. | +| [`.spread()`](/api/commands/spread) | Invoke a callback function with multiple arguments. Similar to `.then()`. | +| [`.spy()`](/api/commands/spy) | Wrap a method in a spy in order to record calls to the function. | +| [`.stub()`](/api/commands/stub) | Replace a method, record its usage and control its behavior. | +| [`.submit()`](/api/commands/submit) | Submit a form. | +| [`.task()`](/api/commands/task) | Execute code in Node via the `task` plugin event. | +| [`.then()`](/api/commands/then) | Invoke a callback function with the current subject, allowing you to execute code at specific points during a Cypress test. | +| [`.tick()`](/api/commands/tick) | Move time after overriding a native time functions with `cy.clock()`. | +| [`.viewport()`](/api/commands/viewport) | Control the size and orientation of the screen for your application. | +| [`.visit()`](/api/commands/visit) | Visit a remote URL. Many tests begin with this command. | +| [`.wait()`](/api/commands/wait) | Wait a number of milliseconds, or wait for an aliased resource to resolve. | +| [`.within()`](/api/commands/within) | Scopes all subsequent cy commands to within this element. Useful when working within a particular group of elements such as a ``. | +| [`.wrap()`](/api/commands/wrap) | Yield the object passed into `.wrap()`. If the object is a promise, yield its resolved value. | +| [`.writeFile()`](/api/commands/writefile) | Write to a file with the specified contents. | ## Cypress API @@ -192,30 +192,30 @@ The _key_ difference between Cypress APIs and Cypress commands is that Cypress APIs execute the moment they are invoked and are **not** enqueued to run at a later time. -| Property | Usage | -| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | -| [`Cypress.arch`](/api/cypress-api/arch) | CPU architecture name of the underlying OS, as returned from Node's `os.arch()`. | -| [`Cypress.browser`](/api/cypress-api/browser) | Information about the current browser, such as browser family and version. | -| [`Cypress.Commands`](/api/cypress-api/custom-commands) | Create new custom commands and extend or override existing ones. | -| [`Cypress.config()`](/api/cypress-api/config) | Get and set Cypress configuration from inside your tests. | -| [`Cypress.Cookies.debug()`](/api/cypress-api/cookies) | Generate console logs whenever a cookie is modified. | -| [`Cypress.currentRetry`](/api/cypress-api/currentretry) | A number representing the current test retry count. | -| [`Cypress.currentTest`](/api/cypress-api/currenttest) | An object with information about the currently executing test. | -| [`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. | -| [`Cypress.dom`](/api/cypress-api/dom) | A collection of DOM related helper methods. | -| [`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). | -| [`Cypress.env`](/api/cypress-api/env) | deprecated Get environment variables from inside your tests. | -| [`Cypress.expose`](/api/cypress-api/expose) | Expose configuration values to the browser context. | -| [`Cypress.isBrowser()`](/api/cypress-api/isbrowser) | Checks if the current browser matches the given name or filter. | -| [`Cypress.isCy()`](/api/cypress-api/iscy) | checks if a variable is a valid instance of cy or a cy chainable. | -| [`Cypress.Keyboard.defaults()`](/api/cypress-api/keyboard-api) | Set default values for how the `.type()` command is executed. | -| [`Cypress.platform`](/api/cypress-api/platform) | The underlaying OS name, as returned by Node's `os.platform()`. | -| [`Cypress.require`](/api/cypress-api/require) | Enables utilizing dependencies within the [cy.origin()](/api/commands/origin) callback function. | -| [`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. | -| [`Cypress.session`](/api/cypress-api/session) | A collection of helper methods related to the `.session()` command. | -| [`Cypress.spec`](/api/cypress-api/spec) | An object with information about the currently executing spec file. | -| [`Cypress.testingType`](/api/cypress-api/testing-type) | The current testing type, eg. `"e2e"` or `"component". | -| [`Cypress.version`](/api/cypress-api/version) | The current Cypress version. | +| Property | Usage | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | +| [`Cypress.arch`](/api/cypress-api/arch) | CPU architecture name of the underlying OS, as returned from Node's `os.arch()`. | +| [`Cypress.browser`](/api/cypress-api/browser) | Information about the current browser, such as browser family and version. | +| [`Cypress.Commands`](/api/cypress-api/custom-commands) | Create new custom commands and extend or override existing ones. | +| [`Cypress.config()`](/api/cypress-api/config) | Get and set Cypress configuration from inside your tests. | +| [`Cypress.Cookies.debug()`](/api/cypress-api/cookies) | Generate console logs whenever a cookie is modified. | +| [`Cypress.currentRetry`](/api/cypress-api/currentretry) | A number representing the current test retry count. | +| [`Cypress.currentTest`](/api/cypress-api/currenttest) | An object with information about the currently executing test. | +| [`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. | +| [`Cypress.dom`](/api/cypress-api/dom) | A collection of DOM related helper methods. | +| [`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). | +| [`Cypress.env`](/api/cypress-api/env) deprecated | Get environment variables from inside your tests. | +| [`Cypress.expose`](/api/cypress-api/expose) | Expose configuration values to the browser context. | +| [`Cypress.isBrowser()`](/api/cypress-api/isbrowser) | Checks if the current browser matches the given name or filter. | +| [`Cypress.isCy()`](/api/cypress-api/iscy) | checks if a variable is a valid instance of cy or a cy chainable. | +| [`Cypress.Keyboard.defaults()`](/api/cypress-api/keyboard-api) | Set default values for how the `.type()` command is executed. | +| [`Cypress.platform`](/api/cypress-api/platform) | The underlaying OS name, as returned by Node's `os.platform()`. | +| [`Cypress.require`](/api/cypress-api/require) | Enables utilizing dependencies within the [cy.origin()](/api/commands/origin) callback function. | +| [`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. | +| [`Cypress.session`](/api/cypress-api/session) | A collection of helper methods related to the `.session()` command. | +| [`Cypress.spec`](/api/cypress-api/spec) | An object with information about the currently executing spec file. | +| [`Cypress.testingType`](/api/cypress-api/testing-type) | The current testing type, eg. `"e2e"` or `"component". | +| [`Cypress.version`](/api/cypress-api/version) | The current Cypress version. | ## Utilities diff --git a/docs/app/core-concepts/introduction-to-cypress.mdx b/docs/app/core-concepts/introduction-to-cypress.mdx index 0e0bbc182c..cd29a2e98b 100644 --- a/docs/app/core-concepts/introduction-to-cypress.mdx +++ b/docs/app/core-concepts/introduction-to-cypress.mdx @@ -413,8 +413,7 @@ Each command specifies what value it yields. For example, yielded `null`, it will look at the entire document. But if the subject is a DOM element, it will only look inside that container. - [`cy.clearCookies()`](/api/commands/clearcookies) does not require a previous - subject - it can be chained off of anything, even - [`.end()`](/api/commands/end). + subject - it can be chained off of anything. #### Examples: