Cypress Cheat Sheet
Cypress Cheat Sheet
Below you’ll find some commands and selectors we think would be valuable for you to use
while doing the exercises:
cy.get('#thisIsAnId')
cy.get('.thisIsAClass')
cy.get('[attribute="value"]')
.contains() – gets the DOM element containing the text/integer
cy.contains('Click me!')
• ‘Getters’ don’t do anything, but they enable you to write clear English sentences
• visible / hidden
cy.get('#errorMessageBox').should('be.visible')
• enabled / disabled
cy.get('Button').should('be.enabled');
• attr(name, value)
• css(name, value)
cy.get('.radioButton1').click();
.dblclick() – double clicks on a DOM element
cy.get('Button').dblclick();
cy.contains('Input').rightclick();
cy.get('.dropDownFruitMenu').select('Bananas');
cy.get('#textBox').clear()
cy.request('https://www.uio.no/studier/emner/matnat/ifi/IN3240/v21/')
• The request method yields the response as an object literal that contains properties
such as:
o Status
o Body
o Headers
o Duration
cy.request('https://www.uio.no/studier/emner/matnat/ifi/IN3240/v21/').then((
response) => {
expect(response.body).to.include('<html lang=\"no\">');
})
To skip a specified suite or test, append .skip() to the function – all nested suites will also
be skipped: