Home > Enterprise >  (uncaught exception)TypeError: $(...).datepicker is not a function
(uncaught exception)TypeError: $(...).datepicker is not a function

Time:12-15

it('Access URL', () => {
  cy.visit('URL')
  cy.wait(5000)
  cy.get('.login-btn').click()
  })

URL is working but login click is not working. (uncaught exception)TypeError: $(...).datepicker is not a function --- is displayed

Trying to access url and trying to click the Login link in the website.

CodePudding user response:

If it takes the page more then 5 seconds to load cypress would never find the button in your code. If you can give the button an id it would be able to find it, but if you can't you can try to add a long timeout to the button and when the button appear on the page it will click it, for example.

`cy.get('.login-btn', { timeout: 30000 }).click()`

CodePudding user response:

By the looks of your comment, you have an uncaught exception in your application. That’s an indication you or a dev needs to fix something in the app. Cypress is just trying to tell you.

If you want to ignore the error, you can add this to your test

it('Access URL', () => {
  cy.once('uncaught:exception', () => false);
  cy.visit('URL')
  cy.wait(5000)
  cy.get('.login-btn').click()
})

If you want to ignore uncaught exceptions in ALL tests you can add this to your support file. (I do NOT recommend this, I recommend fixing your application to find out why it’s throwing an exception in the first place)

// support/index.js
Cypress.on('uncaught:exception', () => false);
  • Related