我需要测试当前日期是否显示在我的设备上,设备上的日期是格式的Monday, September 9, 2018,但是当我尝试测试它时,我只能使用会导致测试失败的格式Monday, 09, 2018,因为月份日期中没有 0。
page should contain element ${DATE}
${DATE_MESSAGE} get current date result_format=%A, %d, %Y
element should contain text ${DATE} ${DATE_MESSAGE}
Run Code Online (Sandbox Code Playgroud)
如何更改 robotsframework 中的格式来验证此格式Monday, September 9, 2018.
错误 should have contained text 'Monday, 09, 2018' but its text was 'Monday, September 9, 2018'.
小智 5
这可以更容易地完成
${date}= 获取当前日期 UTC except_millis=yes
${convert}= 转换日期 ${date} result_format=%a %B %d %H:%M:%S UTC %Y
日志 ${convert} console=yes
(%a = fe Mon
%A = fe Monday
%B = fe May
%H:%M:%S - fe 13:04:09
UTC = fe 需要字符串的一部分
%Y = 2019)
上面字符串的控制台输出将给出:
世界标准时间 2019 年 5 月 10 日星期五 10:12:31
如果您想添加一定的天数,请使用:
${date}= 获取当前日期 UTC except_millis=yes
${plus14}= 添加时间到日期 ${date} 14 天
${future} 转换日期 ${plus14} result_format=%a %B %d %H:%M :%S UTC %Y
日志 ${future} console=yes
输出将是:
世界标准时间 2019 年 5 月 24 日星期五 10:12:31
| 归档时间: |
|
| 查看次数: |
37818 次 |
| 最近记录: |