我如何使用 cy.clock() 获取 dd/mm/yyyy 格式的日期并将日期放入文本字段中。我见过大多数示例都获取时间戳,但我不需要时间。只需要当前日期。
我不想在这里使用自定义命令。谢谢
我们如何使用 DayJs 获取当前日期之前的日期。
我知道如何获取当前日期,但我们可以从当前日期删除 15 天吗?
cy.get('input[name="day"]').should('have.value', (Cypress.dayjs().format('DD')))
cy.get('input[name="month"]').should('have.value', (Cypress.dayjs().format('MM')))
cy.get('input[name="year"]').should('have.value', (Cypress.dayjs().format('YY'))) ```
This is my code for getting the currentDate. I would like to get 15 days before my current Date. I would have used substract if the date was one input field but here we have different placeholders for the inputs.
Run Code Online (Sandbox Code Playgroud)