0

我有步骤:然后字段中的日期:等于'myDate'

通常将数据时间格式数据传输到此步骤,但我有一个特定情况可以检查日期是否为今天,因此我无法对日期进行硬编码

我该如何解决这个问题。请帮忙。

4

1 回答 1

0

Better way in such case is to handle it inside step. For instance,

Then date in field: is equal to today

However, If you are using cucumber version 5+ you can use qaf-cucumber that will enable features from qaf which allows you to use properties.

Below is example.

Then date in field: is equal to '${expr:com.qmetry.qaf.automation.util.DateUtil.getDate(0, 'MM/dd/yyyy')}'

Alternately you can have property that store value for today and use that property. For example: in property file

today = ${expr:com.qmetry.qaf.automation.util.DateUtil.getDate(0, 'MM/dd/yyyy')}

your step:

Then date in field: is equal to '${today}'
于 2020-12-17T23:12:21.873 回答