I am finding difficulties in automating TimePicker through a clock in cypress. The component is through MaterialUI. It clicks on the value but the needle simply doesn't move. Any suggestions?
I am finding difficulties in automating TimePicker through a clock in cypress. The component is through MaterialUI. It clicks on the value but the needle simply doesn't move. Any suggestions?
The clock does not like cy.click() for some reason.
But you can test it with cypress-real-events plugin
install with npm install cypress-real-events
add this line import "cypress-real-events/support"; to the file /cypress/support/e2e.js
Test the clock like this:
cy.get('button[aria-label^="Choose time"]').click()
cy.get('.MuiClockPicker-root').within(() => {
cy.contains('12').realClick() // choose 12 hours
cy.contains('30').realClick() // choose 30 minutes
})
// verify value
cy.get('input[placeholder="hh:mm (a|p)m"]').should('have.attr', 'value', '12:30 PM')
// or
cy.get('input[value="12:30 PM"]')