Automation projects development in Cypress
- node js
# install
npm install cypress
# open
npx cypress open
# package.json init
npm init
- Global timeout in
cypress.json:
{
"defaultCommandTimeout":10000
}cy.get('#input-text', {timeout: 6000}).type('write this text')
cy.wait(6000)
cy.wait('@alias').its('response.statusCode').should('eq', 200)// IMPLICIT ASSERTIONS
// Should
cy.get('#query-btn')
.should('contain', 'button')
.should('have.class', 'query-btn')
//have.text
//have.html
.should('be.visible')
//be.selected
//be.disable
//be.focused igual a have.focus
.should('be.enable')
cy.get('#query-btn').invoke('attr', 'id')
.should('equal', 'query-btn')
cy.get('#query-btn')
.should('contain', 'button')
.and('have.class', 'query-btn')
// EXPLICIT ASSERTIONS
// Expect
let name = 'luis'
expect(name).to.be.equal('luis')
//to.not.equal()
//to.be.a('string')
//to.be.true
//to.be.false
//to.be.null
//to.exist
//Assert
assert.equal(4, 5, 'this value is not equal')
//.notEqual
//.strictEqual
//.isAbove
//.isBelow
//.exists
//.notExists
//.true
//.false
//.isString
//.isNotString
//.isNumber
//.isNotNumber
Add in the cypress.json file:
{
"viewportWidth": 1360,
"viewportHeight": 768
}The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.
Add in the support/index.js file:
import './commands'
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from failing the test
return false
})