# DOM State Clarity With cy.depends Command

DevFeed: [DOM State Clarity With cy.depends Command](<https://devfeed.tech/articles/dom-state-clarity-with-cy-depends-command-28888.md>)

Original publisher: [Read original article](<https://glebbahmutov.com/blog/dom-state-clarity-with-cy-depends/>)

Author: Gleb Bahmutov

Published: 2026-05-22T04:00:00Z

Content type: tutorial

Language: en

Sources: [Gleb Bahmutov](<https://devfeed.tech/sources/gleb-bahmutov.md>)

Topics: [Cypress](<https://devfeed.tech/topics/cypress.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>), [selectors](<https://devfeed.tech/topics/selectors.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>)

Tags: [backend](<https://devfeed.tech/tags/backend.md>), [cypress](<https://devfeed.tech/tags/cypress.md>), [errors](<https://devfeed.tech/tags/errors.md>), [network](<https://devfeed.tech/tags/network.md>), [process](<https://devfeed.tech/tags/process.md>), [selectors](<https://devfeed.tech/tags/selectors.md>), [test](<https://devfeed.tech/tags/test.md>)

## AI overview

This tutorial shows how to use the cy.depends query command from the cypress-if plugin to handle multiple possible DOM outcomes in Cypress tests. It demonstrates waiting for success and error selectors simultaneously and performing an action based on the first selector matched.

## Source excerpt

Imagine a simple web application scenario: you click on a button. App tries to load some data. The data might load, or the backend might