nikolas
nikolas

Reputation: 67

cypress ignore timeout when using timeout

cy.get('#btnPulisciFiltri', { timeout: 15000 }).should('be.visible').click()

use 15sec but cypress ignore this always have

CypressError Timed out retrying after 4050ms: cy.click() failed because this element:

...

Upvotes: 1

Views: 991

Answers (3)

Ben Walding
Ben Walding

Reputation: 4064

If you want an individual test timeout to exceed the defaultCommandTimeout, then you will need to tell Cypress as such.

describe("everything", () => {
  it("tests something", { defaultCommandTimeout: 20000 }, () => { // <1>
    cy.get('#btnPulisciFiltri', { timeout: 15000 }).should('be.visible').click();
  });
});

<1> Note the defaultCommandTimeout setting

The reference for this can be found here - https://docs.cypress.io/guides/references/configuration#Test-specific-Configuration

Upvotes: 0

agoff
agoff

Reputation: 7163

Fody's answer is perfect for applying the timeout to only one command. If you wanted to apply the timeout globally, you can set the timeout value in your cypress.json.

{
  "defaultCommandTimeout": 15000
}

Upvotes: 1

Fody
Fody

Reputation: 32128

It's referring to the .click() which has it's own timeout option

cy.get('#btnPulisciFiltri', { timeout: 15000 })
  .should('be.visible')
  .click({ timeout: 15000 })

What is the full error message?

Upvotes: 3

Related Questions