vendredi 5 mars 2021

How can I DECLINE alert boxes when testing with Cypress?

Cypress auto accepts alert boxes currently but I want to test functionality when we DECLINE the alert box. How can I do this?

Currently, this is my test for accepting the alert box:

describe('Break Tests', () => {
    it('test', () => {
        cy.on('uncaught:exception', (err, runnable) => {
            return false;
        });

        cy.get('#end').click();

        cy.get('#timer').should('have.text', 'Break');
    })
})

When we click the '#end' button, we also execute an alert box which Cypress automatically accepts by default. Then we check if the '#timer' element has an inner text value of break and this works well, but I don't know how to test for DECLINING the alert box after clicking '#end'

Aucun commentaire:

Enregistrer un commentaire