Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 在Run关键字If-Robot框架中处理多个语句_Selenium_Robotframework - Fatal编程技术网

Selenium 在Run关键字If-Robot框架中处理多个语句

Selenium 在Run关键字If-Robot框架中处理多个语句,selenium,robotframework,Selenium,Robotframework,只有在使用Robot框架传递条件时,我才需要执行多个语句 请看代码:注意这是一个示例代码 *** Settings *** Library Selenium2Library Library Collections *** Keywords *** Parent Routine ${isElementExist} Run Keyword And Return Status Element Should Be Visible id=txt1 Run Ke

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

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

*** 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
如果${isElementExist},我不知道如何将
click元素的所有语句捆绑在
Run关键字的范围下


请帮助我。

您可以使用
运行关键字
,它将按顺序执行所有给定的关键字

${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

当然,如果

If语句应该是

Run Keyword If    ${isElementExist}    Run Keywords    click element      id=btn1
...   AND    click element      id=btn2
...   AND    click element      id=btn3
完整的代码是

*** 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

设置测试变量${temp}rxu 如果“${temp}”==“rxu”,则运行关键字 ... 运行关键字 ... 登录到控制台这是一个 ... 并登录到控制台这是两个 ... 否则,运行关键字日志以控制台另一个块

每行前的间距应符合python间距指南