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

41 lines
1.0 KiB
Markdown

title: cypress-jquery
comments: true
---
# [Cypress.$( **selector** )](#section-selector-usage)
Cypress automatically proxies [jQuery](https://jquery.com/) 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`](https://on.cypress.io/api/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`](https://on.cypress.io/api/request)
{% endnote %}
***
# Selector Usage
```javascript
var $li = Cypress.$("ul li:first")
cy
.wrap($li)
.should("not.have.class", "active")
.click()
.should("have.class", "active")
```