Robotframework -:如何检查元素是否已启用然后单击它,否则移动到下一个关键字

Robotframework -: How check if element is enabled then click on it ,else move to next keyword

要检查元素是否已启用然后单击它,否则记录一些消息而不会使脚本失败-:

运行 关键字如果元素应该可见 ${accounts_per_page} 点击 acc_per_page

... ELSE IF LOG“下拉菜单未启用”

我遇到以下错误 -:计算表达式 'element should be visible' 失败:语法错误:语法无效(,第 1 行)

您应该考虑重新设计您的测试。如果您绝对必须使用关键字 运行 关键字并忽略错误 捕获 return 值并将其用作下一个测试步骤的条件,关键字 运行 关键字 If.

*** Test Cases ***   
Example                
    ${output}=    Run Keyword And Ignore Error    Possible Failure
    Log    ${output}[0]
    Run Keyword If    '${output}[0]'=='FAIL'    Keyword With Next Step

如果你使用机器人框架5.0你可以使用新添加的try/catch functionality 示例取自资源。

*** Test Cases ***
First example
    TRY
        Some Keyword
    EXCEPT    Error message
        Error Handler Keyword
    END
    Keyword Outside