Hi all,
I have an issue with my web page.
Basically It has a loader "spinner" which usually shows up after some user-action.
Let's say I confirm selection on a specific page via some Button.
Next, the loader appears. After it is no longer visible, the data is updated on a page and we are ready to go.
Initially I wanted to create a custom command like this:
Cypress.Commands.add('waitForLoaderToFinish', () => {
cy.get('body').then(($body) => {
if ($body.find('.table-loading-spinner').length > 0) {
cy.get('.table-loading-spinner', { timeout: 3000 }).should('be.visible');
cy.get('.table-loading-spinner', { timeout: 3000 }).should('not.exist');
} else {
cy.log('Spinner not present, continuing test execution');
}
});
});
I wanted this command to Check if the .table-loading-spinner is present in the DOM, if so It should wait for this to not exist (disappear).
The issue I'm having is the fact, that the loader "takes some time" to actually appear and Cypress seems to be "too fast".
So as a result, cypress already continues tests assuming that the spinner is not present, but in fact the spinner did not yet appear.
Any ideas how to solve this issue?