I am looking for an alternative to the wait command.
As we all know, a page/component/etc. does not take the same time to load or simply be available every time it is called. For this reason, I cannot rely on the 'wait' command with constant time specification.
So I am looking for an alternative.
Some people on the internet write that the command 'then' helps to wait until the condition is fulfilled. Unfortunately, the following alternative does not work in my case:
cy.get(#element).should('exist').then(() =>{
cy.get(#element).click();
});
I am looking forward to your messages and alternatives to 'wait'. Many greetings Janni
CodePudding user response:
You can chain the assertion and apply a timeout like this:
cy.get('#element',{timeout: 5000}).should('be.visible').click()
What this will do is wait and re-qeuery till 5 seconds till the element is visible on the DOM and then click it.
CodePudding user response:
Thank you for your answer.
The problem was that the default timeout had to be increased.
Cypress.config('pageLoadTimeout', 300000);
