This article will discuss how to type in date, month, week, and time in cypress using the command type().
For Date:
The correct format for date when provided with date input(<input type="date">) is,
yyyy-MM-dd
For Month:
The correct format for month when provided with month input(<input type="month">) is,
yyyy-MM
For Week:
The correct format for week when provided with week input(<input type="week">) is,
yyyy-Www
- W is the character, and ww is the literal number of weeks.
For Time:
The correct format for time when provided with time input(<input type="time">) is,
HH:mm
HH:mm:ss
HH:mm:ss.SSS
Example:
it('DMWT',() => {
cy.visit("dmtw.html")
cy.xpath("//input[@type='date']").type('2022-12-13')
cy.xpath("//input[@type='month']").type('2022-12')
cy.xpath("//input[@type='week']").type('2022-W23')
cy.xpath("//input[@type='time']").type('06:10')
})
- It is working as expected, and this is how we should follow when date, month, week, and time inputs are involved in cypress.
- Log in to post comments