I am automating using cypress, there is a time input in the application. The html of it as follows:

<input data-testid="time" type="time" name="time" class="u-full-width" value="" wtx-context="95580C00-C3AB-4D06-ADCC-29340AA4B7E2">

The code that I used to identify the element is:

        return cy.get('[data-testid=time]');

Code to enter data in it is:

 formCreateAppointmentPageElements.timeInput().click().type("01:52:08 AM");

When I run the test, cypress gives this error:

Typing into a time input with cy.type() requires a valid time with the format HH:mm, HH:mm:ss or HH:mm:ss.SSS, where HH is 00-23, mm is 00-59, ss is 00-59, and SSS is 000-999. You passed: 01:52:08 AM Learn more
   7 |         formCreateAppointmentPageElements.ownerNameInput().type("Reena");
   8 |         formCreateAppointmentPageElements.dateInput().click().type("2022-01-23");
>  9 |         formCreateAppointmentPageElements.timeInput().click().type("01:52:08 AM");
     |                                                               ^

Also, cypress does type 01:52:08 AM in the time input, highlights the 01 and throws the error. But the error says, you passed, what does that mean? Am I not providing the time in the right format? How can I resolve this?

1 Answer 1


It seems there are only three allowed formats for input type time:

  • HH:mm (e.g. 01:30 or 23:15)

  • HH:mm:ss (e.g. 10:00:30)

  • HH:mm:ss.SSS (e.g. 12:00:00.384)

You can also use .invoke() command:

  .invoke('val', '01:52:08 AM');

Basically whatever is possible in JavaScript is possible in Cypress. So here you can invoke jQuery val() method.

  • Thankyou! If I eliminate the Am/PM it works fine!
    – RenukaA
    Commented Jan 18, 2022 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.