gpt4 book ai didi

selenium - 机器人框架中有else语句吗?

转载 作者:行者123 更新时间:2023-12-02 22:07:37 26 4
gpt4 key购买 nike

我正在机器人框架中运行以下关键字:

Welcome Page Should Be Open
Run Keyword If '${BROWSER}' == 'IE' Location Should Be ${LOGIN URL IE}
Run Keyword If '${BROWSER}' != 'IE' Location Should Be ${LOGIN URL}
Wait Until Page Contains Accounts 5s
Page Should Contain Accounts

而不是有 2 个 Run 关键字 If 语句,我想知道机器人是否有一个可以使用的 else 语句或可以使用的 OR 语句?

干杯

最佳答案

从机器人框架2.7.4版本开始,您可以在调用 Run keyword if 时使用 ELSE .

来自the documentation :

Starting from Robot version 2.7.4, this keyword supports also optional ELSE and ELSE IF branches. Both of these are defined in *args and must use exactly format ELSE or ELSE IF, respectively. ELSE branches must contain first the name of the keyword to execute and then its possible arguments. ELSE IF branches must first contain a condition, like the first argument to this keyword, and then the keyword to execute and its possible arguments. It is possible to have ELSE branch after ELSE IF and to have multiple ELSE IF branches.

例如(为了清楚起见,我使用管道分隔格式和延续功能):

| | Run Keyword If | '${BROWSER}' == 'IE'
| | ... | Location should be | ${LOGIN URL IE}
| | ... | ELSE
| | ... | Location should be | ${LOGIN_URL}

关于selenium - 机器人框架中有else语句吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25284356/

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