小编Zom*_*Pie的帖子

如何使用 cy.clock() 获取当前日期

我如何使用 cy.clock() 获取 dd/mm/yyyy 格式的日期并将日期放入文本字​​段中。我见过大多数示例都获取时间戳,但我不需要时间。只需要当前日期。

我不想在这里使用自定义命令。谢谢

javascript cypress

4
推荐指数
2
解决办法
3万
查看次数

使用 dayjs 获取 beforeDate

我们如何使用 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)

javascript cypress

3
推荐指数
1
解决办法
4298
查看次数

标签 统计

cypress ×2

javascript ×2