Cypress.$

Improve this doc

Cypress automatically includes jQuery and exposes it as Cypress.$.

Calling Cypress.$('button') will automatically query for elements in your remote window. In other words, Cypress automatically sets the document to be whatever you’ve currently navigated to via cy.visit().

This is a great way to synchronously query for elements when debugging from Developer Tools.

Syntax

Cypress.$(selector)

// other proxied jQuery methods
Cypress.$.Event
Cypress.$.Deferred
Cypress.$.ajax
Cypress.$.get
Cypress.$.getJSON
Cypress.$.getScript
Cypress.$.post

Usage

Correct Usage

Cypress.$('p')

Incorrect Usage

cy.$('p') // Errors, cannot be chained off 'cy'

Examples

Selector

const $li = Cypress.$('ul li:first')

cy.wrap($li)
  .should('not.have.class', 'active')
  .click()
  .should('have.class', 'active')