cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.97k stars 3.18k forks source link

cy.click() failed because it requires a DOM element, failure in after each #8275

Closed khaledjawhar closed 4 years ago

khaledjawhar commented 4 years ago

Current behavior:

I am running a bunch of tests in a fixture and from time to time and I am having the failure: cy.click() failed because it requires a DOM element. It occured in this line: cy.get(Cypress.env('page.commandButton')).click();

Desired behavior:

I expect the fixture to always pass without having this flaky result

Test code to reproduce

context('SomeFixture', () => { before(() => { cy.visit('') })

beforeEach(() => {
    cy.login(Cypress.env('mUser'), Cypress.env('mPassword'))  
    cy.clickButton(Cypress.env('page.memorytab'))  
})

afterEach(() => {
    cy.reload()
    cy.logout()
})

Cypress.Commands.add("logout", () => { cy.get(Cypress.env('page.commandButton')).click(); cy.get(Cypress.env('page.signoutButton')).click();
}) //some tests exist here but regardless of what tests exist, the failure is happening always in the after each block. The failure is not happening in a specific test, it occurs in the after each for various tests. The code above will help reproducing the problem })

Versions

jennifer-shehane commented 4 years ago

Duplicate of #8274