Why can't I get the content of a global variable (attached to the window object?) with Cypress?
I've tried many different things and ended up with this, which still doesn't work:
it('blabla', () => {...
cy.window()
.then((win) => {
cy.log(cy.window().abc);
cy.window().should('have.property', 'abc', true);
win.abc.forEach(function (el, i) {
cy.get('h1').should('be.visible');
cy.get('h1').should('have.text', win.abc[i]);
cy.tick(11800);
});
})
...});
It errors with TypeError: Cannot read property 'forEach' of undefined.
I've read through the docs related to the cy.window() function, and I can't understand how their examples differ from mine. I've also (as in the example on 'Check custom property') assigned cy.window().teasers to a variable in the first .then() and created a second .then() referencing that variable, but that wouldn't work either.
Any help is appreciated, thanks.
Aucun commentaire:
Enregistrer un commentaire