gpt4 book ai didi

robotframework - 机器人框架中的 IF block

转载 作者:行者123 更新时间:2023-12-04 06:37:28 25 4
gpt4 key购买 nike

我们能否在 IF 部分中执行一个关键字 block ,并可选择使用 ELSE/ELSE IF 部分?它可以像下面这样:

Run keyword If  ${x} == "Simple"
Keyword1 [arg1] [arg2]
Keyword2 [arg3]
Keyword3 [arg4] [arg5]
ELSE
Keyword4 [arg6]
END IF

最佳答案

Run Keyword If 不支持调用多个关键字,但可以运行关键字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

关于robotframework - 机器人框架中的 IF block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26097539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com