Show Menu
Cheatography

Cypress.io Cheat Sheet by

Cheat sheet for using Cypress.io testing suite. Sponsered by Geonotebook. Learn more at: https://www.geonotebook.com/

Context and Hooks

describe
group & label tests + manage context & hooks
it
label a test block
before
hook that runs before all tests in contex­t/d­escribe
after
hook that runs after all tests in contex­t/d­escribe
beforeEach
hook that runs before each tests in contex­t/d­escribe
afterEach
hook that runs after each tests in contex­t/d­escribe

.should & Common Chainers

.should
command used for asserting tests. (docs)
"­hav­e.c­las­s"
check for class
"­hav­e.c­ss"
check for CSS style
"­be.v­is­ibl­e"
check if visible. (docs)
"­exi­st"
check if element exists
"­hav­e.l­eng­th"
checks for number of matching elements
"­hav­e.v­alu­e"
checks the value of input field
"­be.c­he­cke­d"
checks for state of radio or checkbox
"­con­tai­ns"
checks value within opening and closing tags.

Utility Commands

cy.log
log comment to command log
cy.fixture
yeilds fixture (docs)
.then( callback )
work with yeilded subject
.wait
wait a certain amount of ms (docs)
.pause
stop testing at certain point
.then( callback )
work with yeilded subject
.scree­nshot
take a screenshot of state of DOM
.debug
print debug info to the console
 

Selection Commands

cy.get
select based on HTML tag attrs
cy.con­tains
select based value within opening and closing tags
.first
select first matching element
.last
select last matching element
.next
select next matching element
.prev
select previous matching element
.parents
select parent of element
.children
select child of element
.siblings
select sibling of element
.closest
find closest element
.find
find matching child element

Action Commands

.click
click on an element
.dblclick
double click on an element
.right­click
right click on an element
.type(­"­foo­bar­")
type "­foo­bar­" into an element
.clear
clear all text from an element
.check
check a checkbox or radio
.uncheck
uncheck a checkbox or radio
.focus
focus on an element
.blur
blur an element
.submit
submit a form.
.trigg­er(­''c­lic­k")
trigger any DOM event
.hover
hover over an element (docs)
.select
select option from a dropdown menu
https:­//d­ocs.cy­pre­ss.i­o/­api­/ap­i/t­abl­e-o­f-c­ont­ent­s.html
All commands are on the side bar under "­Com­man­ds."­

Browser Commands

cy.visit
visit url
cy.go(­"­bac­k")
click on browser's "­bac­k" button
cy.go(­"­for­war­d")
click on browser's "­for­war­d" button
cy.reload
refresh the page
cy.vie­wport
change window size
cy.url
yeilds current url
cy.window
yeilds current window object
cy.title
yeilds docume­nt.t­itle object
.scrol­lIn­toView
scroll element into view
.scrollTo
scroll to position in the window
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Selenium WebDriver Cheat Sheet Cheat Sheet
          Cypressio Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet