W3cubDocs

/Cypress

Cypress.dom

Cypress.dom.method() is a collection of DOM related helper methods.

There are actually dozens of methods attached to Cypress.dom that are not documented below. These methods are used internally by Cypress in nearly every single built in command.

We suggest reading through the source code here to see all of the methods and what they do.

Syntax

Cypress.dom.isHidden(element)

Examples

Is detached

Returns a boolean indicating whether an element is detached from the DOM.

cy.get('button').then(($el) => {
  Cypress.dom.isDetached($el) // false
})

Is focusable

Returns a boolean indicating whether an element can receive focus.

Cypress internally uses this method everywhere to figure out whether an element is hidden, mostly for actionability.

cy.get('input').then(($el) => {
  Cypress.dom.isFocusable($el) // true
})

Is hidden

Returns a boolean indicating whether an element is hidden.

Cypress internally uses this method everywhere to figure out whether an element is hidden, mostly for actionability.

cy.get('p').then(($el) => {
  Cypress.dom.isHidden($el) // false
})

Is scrollable

Returns a boolean indicating whether an element is scrollable.

Cypress internally uses this method everywhere to figure out whether an element can be scrolled, mostly for actionability.

cy.get('body').then(($el) => {
  Cypress.dom.isScrollable($el) // true
})

Is visible

Returns a boolean indicating whether an element is visible.

cy.get('img').then(($el) => {
  Cypress.dom.isVisible($el) // true
})

© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/cypress-api/dom.html