我们可以在IF部分中执行一个关键字块,也可以选择使用ELSE / ELSE IF部分吗?它可能如下所示:
Run keyword If ${x} == "Simple"
Keyword1 [arg1] [arg2]
Keyword2 [arg3]
Keyword3 [arg4] [arg5]
ELSE
Keyword4 [arg6]
END IF
答案 0 :(得分:3)
运行关键字如果不支持调用多个关键字,但您可以运行关键字Run Keywords,这样您就可以运行多个关键字。
例如:
*** Test Cases ***
| Example of running multiple keywords with "Run keyword if" and "Run keywords"
| | ${x}= | Set variable | Simple
| | Run keyword if | "${x}" == "Simple" | Run keywords
| | ... | log to console | this is keyword one
| | ... | AND | log to console | this is keyword two
| | ... | ELSE
| | ... | log to console | this is keyword three
当然,您始终可以创建其他关键字:
*** Keywords ***
| Handle the simple case
| | log to console | this is keyword one
| | log to console | this is keyword two
| Handle the complex case
| | log to console | this is keyword three
*** Test Cases ***
| Example of using separate keywords for "Run keyword if"
| | ${x}= | Set variable | Simple
| | Run keyword if | "${x}" == "Simple"
| | ... | Handle the simple case
| | ... | ELSE
| | ... | Handle the complex case