javascriptcypressui-automationvisibilitycypress-wait-until

Not able to override default timeout while using explicit wait mechanism in cypress


I am using cypress-wait-until plugin to apply explicit wait in our framework. When I use it and maximum time given is say 30000 milliseconds, so ideally it should wait maximum 300000 ms (30 seconds) for element to be visible but it timesout after 4 seconds which is a default timeout for cypress commands.

    cy.waitUntil(() => cy.get('div.tabs div:nth-child(3)').should('be.visible') ,{timeout:30000})

I would like to know what changes I should and in which file so that I can override default timeout prescribed for cypress. It would be great if community provides some solution in this regard.


Solution

  • If you want to use cy.waitUntil(), change cy.get() to jQuery. That way the only timeout active is the one provided to cy.waitUntil().

    cy.waitUntil(() => {
      return Cypress.$('div.tabs div:nth-child(3):visible').length
    }, {timeout:30000})