首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Run Keyword If - Robot框架中处理多条语句

在Run Keyword If - Robot框架中处理多条语句
EN

Stack Overflow用户
提问于 2017-06-27 20:29:06
回答 3查看 8.6K关注 0票数 2

只有当使用Robot Framework传递条件时,我才需要执行多个语句

请看下面的代码:注意这是一个示例代码

代码语言:javascript
复制
*** Settings ***
Library    Selenium2Library
Library    Collections

*** Keywords ***
Parent Routine
    ${isElementExist}    Run Keyword And Return Status    Element Should Be Visible   id=txt1
    Run Keyword If    ${isElementExist}     click element      id=btn1
    Run Keyword If    ${isElementExist}     click element      id=btn2
    Run Keyword If    ${isElementExist}     click element      id=btn3

*** Test Cases ***
Sample Test Case
    [Documentation]   Simple test for If Condition
    Parent Routine

我不知道如何将click element的所有语句捆绑到Run Keyword If ${isElementExist}范围内。

请帮帮我。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-06-27 20:41:49

当然,我们可以在Run Keyword If中执行多个语句

If语句应该是

代码语言:javascript
复制
Run Keyword If    ${isElementExist}    Run Keywords    click element      id=btn1
...   AND    click element      id=btn2
...   AND    click element      id=btn3

完整的代码是

代码语言:javascript
复制
*** Settings ***
Library    Selenium2Library
Library    Collections

*** Keywords ***
Parent Routine
    ${isElementExist}    Run Keyword And Return Status    Element Should Be Visible   id=txt1
    Run Keyword If    ${isElementExist}    Run Keywords    click element      id=btn1
    ...   AND    click element      id=btn2
    ...   AND    click element      id=btn3

*** Test Cases ***
Sample Test Case
    [Documentation]   Simple test for If Condition
    Parent Routine
票数 5
EN

Stack Overflow用户

发布于 2017-06-27 20:32:11

您可以使用Run Keywords,它将在一个序列中执行所有给定的关键字。

代码语言:javascript
复制
${isElementExist}    Run Keyword And Return Status    Element Should Be Visible   id=txt1
Run Keyword If    ${isElementExist}     Run Keywords    click element      id=btn1
...    AND    click element      id=btn2
...    AND    click element      id=btn3
票数 1
EN

Stack Overflow用户

发布于 2018-06-06 00:01:48

如果' ${temp} '==' rxu‘,则设置测试变量${temp}rxu运行关键字...运行关键字...登录控制台这是一个...然后登录控制台这是2 ..。否则,运行关键字日志来控制另一个块

每行前的空格应符合python间距准则。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44780327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档