如何在 Robot Framework 中获取当前日期?
How can I get the current day in Robot Framework?
我是自动化测试的新手。
现在我想从列表中 select 当前工作日。
我想给我们以下关键字:
Selenium2Library.Select From List by Value ${day_of_the_week}
如何在 Robot Framework 中获取当前日期?我的问题有简单的解决方案吗?
最好是一个用德语告诉我当天的变量。
希望你能帮帮我。
使用 Library DateTime
可以通过以下方式调用:
**** Settings ***
Library DateTime
您可以使用 Get Current Date
关键字并将其分配给 Var 并指定格式。例如:
${CurrentDate} Get Current Date result_format=%d-%m-%Y
Log ${CurrentDate}
在您的情况下,您需要更改 Result_format
以检索当前日期。这将是
${CurrentDay} Get Current Date result_format=%A
Log ${CurrentDay}
在日志中查看时,将检索 "Thursday"
可以找到格式列表here
希望对您有所帮助!
编辑:
由于 DateTime
库不支持日期的本地名称(例如德语中的 Montag 表示星期一)提问者将 %w
格式切换为 return 0-6范围。然后使用索引将int更改为日期的字符串!
我是自动化测试的新手。
现在我想从列表中 select 当前工作日。
我想给我们以下关键字:
Selenium2Library.Select From List by Value ${day_of_the_week}
如何在 Robot Framework 中获取当前日期?我的问题有简单的解决方案吗?
最好是一个用德语告诉我当天的变量。
希望你能帮帮我。
使用 Library DateTime
可以通过以下方式调用:
**** Settings ***
Library DateTime
您可以使用 Get Current Date
关键字并将其分配给 Var 并指定格式。例如:
${CurrentDate} Get Current Date result_format=%d-%m-%Y
Log ${CurrentDate}
在您的情况下,您需要更改 Result_format
以检索当前日期。这将是
${CurrentDay} Get Current Date result_format=%A
Log ${CurrentDay}
在日志中查看时,将检索 "Thursday"
可以找到格式列表here
希望对您有所帮助!
编辑:
由于 DateTime
库不支持日期的本地名称(例如德语中的 Montag 表示星期一)提问者将 %w
格式切换为 return 0-6范围。然后使用索引将int更改为日期的字符串!