在下面的测试案例中,如果关键字将创建时检索的系统时间与布局中记录的时间进行比较,则应执行第二个关键字将时间添加到系统时间,将其与布局中记录的时间进行比较,如果第二个关键字也失败,则应跳出第三个关键字从系统时间中减去时间,并将其与布局中记录的时间进行比较。请帮助我将其构造为验证最后修改/创建的估算值居榜首
中的条件语句*** Settings ***
Resource ../settings.robot
*** Variables ***
${modified_date_row_1} css=#estimateTable > tbody > tr.item-name.highlighted > td:nth-child(4)
*** Test Cases ***
Last modified/created estimates should top the list of estimates displayed
Verify that the last last modified/created estimate tops the list
*** Keywords ***
Compare system time retrieved at the time of creation with time recorded in the layout
Sleep 5s
${get_modified_date_row_1} Get Text ${modified_date_row_1}
${compare} Should Be Equal ${get_modified_date_row_1} ${date_time}
Add time to sys time and compare it with time recorded in the layout
Sleep 5s
${get_modified_date_row_1} Get Text ${modified_date_row_1}
${add_time} Add Time To Date ${sys_date_time} 01:00
${converted_add_time} Convert Date ${add_time} result_format=%b %d %Y %I:%M %p
${compare} Should Be Equal ${get_modified_date_row_1} ${converted_add_time}
Subtract time from sys time and compare it with time recorded in the layout
Sleep 5s
${get_modified_date_row_1} Get Text ${modified_date_row_1}
${subtract_time} Subtract Time From Date ${sys_date_time} 01:00
${converted_sub_time} Convert Date ${subtract_time} result_format=%b %d %Y %I:%M %p
${compare} Should Be Equal ${get_modified_date_row_1} ${converted_sub_time}
Verify that the last last modified/created estimate tops the list
Run Keyword If Compare system time retrieved at the time of creation with time recorded in the layout == 'FAIL' Add time to sys time and compare it with time recorded in the layout
... ELSE IF Add time to sys time and compare it with time recorded in the layout == 'FAIL' Subtract time from sys time and compare it with time recorded in the layout
答案 0 :(得分:0)
获取关键字的状态,并将其作为条件应用于第4个关键字,如下例所示:
Verify that the last last modified/created estimate tops the list
${Status1}= Run Keyword and Return Status Compare system time retrieved at the time of creation with time recorded in the layout
${Status2}= Run Keyword If '${Status1}'=='Fail' Run Keyword and Return Status Add time to sys time and compare it with time recorded in the layout
Run Keyword If '${Status1}'=='Fail' And '${Status2}'=='Fail' Subtract time from sys time and compare it with time recorded in the layout