Search code examples
javascriptjqueryautomationcypresswait

Cypress waitUntill retiers after 400ms, how to prolong its timeout?


I am working on a progress bar.

I click on a button that initiates the progress bar Then I used waitUntill to wait till the progress bar (cyElement) is not visible I verify that a second control (cyElement2) is now visible

cy.waitUntil(()=> {
            cy.get(cyElement).should('not.be.visible')
              
        }).then(()=>{ cy.get(cyElement2).should('be.visible') });

The below code waits only 400ms to check if the progress bar (cyElement) is not visible. How do I make it wait longer ? Adding timeout=40000 will destroy the purpose of waitUntill.


Solution

  • cy.waitUntil(()=> {
                cy.get(cyElement, {timeout:180000}).should('not.be.visible')
                  
            }).then(()=>{ cy.get(cyElement2).should('be.visible') });
    

    So it happens that if we add timeout in get command, the subsequent commands to this get will also get the same timeout.

    And if I add a timeout of 10 minutes but the assertions get passed in 3 minutes then cypress will move over to the next command. So adding timeout does not mean hardcoding wait it is similar to explicit wait in selenium

    Refer : https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Applying-Timeouts