☝️10. Cypress Assertions(iddia)

Cypress, Mocha ve Chai gibi çeşitli kütüphanelerden elde edilen birden fazla assertion türüne sahiptir.

Implicit Assertions

describe('Assertion Lesson', function () {
  it('Scenario 1', function (){
 
 // test step to launch a URL
 cy.visit("https://www.iddaa.com")
 
 // assertion to validate count of sub-elements and class attribute value
 cy.get('.toc chapters').find('li').should('have.length',5)
    .and('have.class', 'dropdown')
  });
});

Explicit Assertions

describe('Tutorialspoint', function () {
 // it function to identify test
    it('Scenario 1', function (){
       // test step to launch a URL
       cy.visit("https://accounts.google.com")
       // identify element
       cy.get('h1#headingText').find('span').then(function(e){
       const t = e.text()
       // assertion expect
       expect(t).to.contains('Sign')
     })
   })
})

Diğer Cypress Assertionları

  • cy.visit ()

  • cy.request ()

  • cy.contains ()

  • cy.get ()

  • .find ()

  • .type ()

  • .click ()

  • .its ()

cy.get('#txt-fld').should('have.length',5)
cy.get(' #txt-fld').should('have.value', 'Cypress')
cy.get('#txt-fld'').should('have.class', 'txt')
cy.get('#txt-fld'').should('contain', 'Cypress')
cy.get('#txt-fld'').should('be.visible')
cy.get('#txt-fld'').should('not.exist');
cy.get('#txt-fld'').should('have.css', 'display', 'block');

Last updated