RobotFramework-获取当前日期 [英] RobotFramework - get current Date

查看:1694
本文介绍了RobotFramework-获取当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试设备上显示的当前日期,设备上的日期格式为Monday, September 9, 2018,但是当我尝试对其进行测试时,我只能使用Monday, 09, 2018格式,该格式会导致测试失败该月的日期中没有0.

I need to test that the current date is displayed on my device, The date on the device is in format Monday, September 9, 2018 but when i try to test it i can only use the format Monday, 09, 2018 which would fail the test as there is no 0 in the Month date.

    page should contain element  ${DATE}
    ${DATE_MESSAGE}  get current date  result_format=%A, %d, %Y
    element should contain text  ${DATE}  ${DATE_MESSAGE}

如何在robotframework中更改格式以验证其格式为Monday, September 9, 2018.

How can change the format in robotframework to verify THis format Monday, September 9, 2018.

错误 should have contained text 'Monday, 09, 2018' but its text was 'Monday, September 9, 2018'.

推荐答案

类似的方法应该起作用:

Something like that should work:

${now}    Evaluate    '{dt.day}/{dt.month}/{dt.year}'.format(dt=datetime.datetime.now())    modules=datetime

更新后:

${now}    Evaluate  '{dt:%A}, {dt:%B} {dt.day}, {dt.year}'.format(dt=datetime.datetime.now())    modules=datetime

这篇关于RobotFramework-获取当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆