${time} = Get Time time=NOW + 1h 2min 3s # 1h 2min 3s 添加到本地时间
${time} = Get Time time=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
Acc.to Get Time Keyword in BuiltIn Library in Robot
${time} = Get Time time=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
${time} 不是 YYYY-MM-DD hh:mm:ss 格式,而是具有以下值
${time} = 27
你能解释一下为什么吗?
在关键字 Get Time 的 Robot Framework 文档中提到了两个参数:
format=timestamp, time_=NOW
您可以看出您的示例缺少 _
*** Test Cases ***
Test Time
${time} = Get Time time_=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
log to console ${time}
导致:
INFO : ${time} = 2020-01-18 17:24:16
如果您仔细查看文档,"time" 参数实际上被命名为 time_
而不是 time
(注意结尾的下划线)。由于您没有使用结尾的下划线,因此机器人会将 `time=NOW + 1h 2m 3s" 解释为格式。
因为格式字符串(它 认为 是格式字符串)包含字符串 "min" 它认为您想要返回分钟。由于它将此参数视为格式字符串,因此请求的时间默认为当前时间。如果您等待一分钟,然后 运行 再次进行测试,结果将改变 1。
如果您使用 time_
的正确参数名称,您的代码将按预期工作。例如:
${time} = Get Time time_=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
Acc.to Get Time Keyword in BuiltIn Library in Robot
${time} = Get Time time=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
${time} 不是 YYYY-MM-DD hh:mm:ss 格式,而是具有以下值
${time} = 27
你能解释一下为什么吗?
在关键字 Get Time 的 Robot Framework 文档中提到了两个参数:
format=timestamp, time_=NOW
您可以看出您的示例缺少 _
*** Test Cases ***
Test Time
${time} = Get Time time_=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
log to console ${time}
导致:
INFO : ${time} = 2020-01-18 17:24:16
如果您仔细查看文档,"time" 参数实际上被命名为 time_
而不是 time
(注意结尾的下划线)。由于您没有使用结尾的下划线,因此机器人会将 `time=NOW + 1h 2m 3s" 解释为格式。
因为格式字符串(它 认为 是格式字符串)包含字符串 "min" 它认为您想要返回分钟。由于它将此参数视为格式字符串,因此请求的时间默认为当前时间。如果您等待一分钟,然后 运行 再次进行测试,结果将改变 1。
如果您使用 time_
的正确参数名称,您的代码将按预期工作。例如:
${time} = Get Time time_=NOW + 1h 2min 3s # 1h 2min 3s added to the local time