Type event time in hours minutes and seconds

Viewed 29

I have a simple form on the page that should take datetime values to the second.

<form>
  <label for="eventNotificationTime">Event time (date and time):</label>
  <input type="datetime-local" id="eventNotificationTime" name="eventNotificationTime">
  <input type="submit">
</form>

When I try to test it I get an error

CypressError
Typing into a datetime input with cy.type() requires a valid datetime with the format YYYY-MM-DDThh:mm, for example 2017-06-01T08:30. You passed: 2022-08-03T09:09:09

How do I enter a time containing seconds?

Test:

cy.get('#eventNotificationTime').clear().type('2022-08-03T09:09:09')
2 Answers

You need to add step="1" to achieve it:

<input type="datetime-local" step="1" id="eventNotificationTime" name="eventNotificationTime" />
Related