我想在RobotFramework中创建一个下周六返回的函数。
*** Settings ***
Library SeleniumLibrary
Library DateTime
*** Keywords ***
Get Next saturday
${today}= Get Time
${today_day}= Convert Date ${today} result_format=%a
${next_saturday}= ????
${next_saturday_formated}= Convert Date ${next_saturday} result_format=%d/%m/%Y
[Return] ${next_saturday_formated}
在问这个问题之前,我会尝试
${next_saturday}= Set Variable If "${today_day}"=="Fri" ...
答案 0 :(得分:3)
使用关键字Get Current Date
,您可以获得工作日索引并计算周六之前的天数,然后使用从未来产生日期的天数。最终关键字如下所示:
Get Next Saturday
${day_index} Get Current Date result_format=%w
${till_saturday} Evaluate 6 - ${day_index}
${saturday} Get Current Date increment=${till_saturday} days result_format=%d/%m/%Y
Return From Keyword ${saturday}