Handle Calendar Event using Cypress- Select Current Date

Let us consider a scenario for UI automation where we are required to select current date for our testing purpose. This problem can easily be solved in cypress. Cypress is a go to automation tool for applications built using Angular, react js etc…because of it’s easy of use and also speed.

Select current date using “Cypress.moment” method.
Cypress.moment will help us to parse or format the date.

cy.get('#DateTimeInput').click().type(Cypress.moment().format('MMM DD, YYYY'))

Approach will be, get the locator of input box of calendar and clicking on that input box will open the Calendar. In the input box we would type the current date as per month, date and year format.

Output: The output date will be typed as
September 16, 2020.

--

--

Saicharan Vadderaju

Automation tester with experience working on different web automation tools like Selenium WebDriver with Java, Cypress.io and Rest Assured for API automation.