Files
cypress/docs/source/api/utilities/$.md
T
2017-05-15 14:10:01 -04:00

1.0 KiB

title: cypress-jquery comments: true

Cypress.$( selector )

Cypress automatically proxies 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 Chrome Dev Tools.


Other proxied jQuery methods

  • Cypress.$.Event
  • Cypress.$.Deferred
  • Cypress.$.ajax
  • Cypress.$.get
  • Cypress.$.getJSON
  • Cypress.$.getScript
  • Cypress.$.post

{% note info %} If you're looking to make an XHR request in your test scripts, use cy.request {% endnote %}


Selector Usage

var $li = Cypress.$("ul li:first")

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